Atproto Oauth Login

by @zzstoatzz.io · created Sep 20, 2026

Install this skill

npx @skillz.supply/cli install did:plc:xbtmt2zjwlrfegqvch7fboei/skills.atproto-oauth-login

Writes SKILL.md into your agent's skills folder under this skill's name. No CLI? Download the file, or view it.

name: "atproto-oauth-login"

description: "Use when adding sign-in to an app for AT Protocol accounts (Bluesky, Blacksky, any PDS handle): the login page and handle typeahead, browser or native OAuth clients, writing records to the user's own repo, or proving who is calling to your own backend with service auth instead of session cookies."

createdAt: "2026-09-20T00:14:06.047938+00:00"

repoUrl: "https://skillz.supply/skills/did:plc:xbtmt2zjwlrfegqvch7fboei/skills.atproto-oauth-login/SKILL.md"

# atproto OAuth login

If the repository already signs people in, follow its implementation and use
this skill to check it, not to replace it.

## where OAuth runs

Default: **the client holds the OAuth session and the server holds no account
credentials.**

- The browser (`@atcute/oauth-browser-client`) or native app holds the
  DPoP-bound tokens and writes records straight to the account's PDS.
- Your backend is a read-only appview. It learns about records from the
  firehose or Jetstream. After a write, the client waits for the appview to
  index that record's URI and CID. It does not ask the server to do the write.
- When the backend needs to know who is calling (queue, settings, an
  allowlist, an admin route), the client sends a **service-auth JWT**. The
  account's PDS signs it with the account's key, for your service's DID and
  one XRPC method. The server checks it against the issuer's DID document.
  Read `references/service-auth.md` before building this.
- Operational state (sessions, settings, queues, metrics) stays in your
  service's store, not in records.

Run a **server-side OAuth client** only when the server has to act as the
user while the user is absent, for example a scheduled job reading their
notifications, or an MCP server that has to be a standard OAuth server to
its own clients. Then the browser gets an opaque session cookie, and
`references/server-client.md` applies.

Never run both a browser client and a server client for one sign-in. Each is
its own `client_id`, so the user gets two consent screens.

## scopes

- `atproto` alone means sign-in only. Add `repo:<collection>?action=…` for
  each record type the client writes, `blob:<mime>` for uploads, and
  `rpc:<lxm>?aud=<service-did>#<service-id>` for each service-auth method.
  A bare DID as `aud` is not valid in the scope: the PDS drops that
  permission at approval without an error, and the session comes back
  narrower than requested.
- Ask for what the first screen needs and add more later. The authorization
  server only shows consent for scopes not granted before, so asking again
  for granted scopes is a silent redirect.
- Name each `lxm` for what it authorizes. A permission named after another
  feature turns into a misleading consent string.
- Not every PDS supports newer capabilities (permission sets, spaces). A
  missing capability can disable an extra feature, never sign-in or basic
  writes.

## login page

One heading, one handle input with typeahead, one primary button. Point the
typeahead at `https://typeahead.waow.tech/xrpc/app.bsky.actor.searchActorsTypeahead`
with an `X-Client` header naming the app. Reuse the app's existing design
tokens.

Before redirecting, resolve the handle and show who is signing in and where
they are going: an avatar row under the input and a button reading
`continue at <host>`, where `<host>` is the account's OAuth authorization
server (`bsky.social` for Bluesky-hosted accounts, the PDS for most
self-hosted ones). Without it, someone new to atproto is dropped on a
sign-in page they never chose.

The full behavior spec (the preview, normalization, keyboard,
password-manager opt-out, errors, `return_to`) is in
`references/login-page.md`; read it before writing the page.

## gotchas

- Local dev opens the app at `http://127.0.0.1:<port>`, never `localhost`.
  The loopback `client_id` is `http://localhost` and the redirect URI uses
  `127.0.0.1`; `localhost` fails validation with an error that does not say
  why. Client metadata details are in `references/client-metadata.md`.
- Derive `client_id` and `redirect_uris` from the request origin, so preview,
  staging and production each serve their own metadata.
- Never trust a DID that the client claims about itself: not in a header, a
  body, or a cookie. The only proof is a verified service-auth JWT or a
  server-side OAuth session.
- Allowlists store DIDs, not handles. Resolve the typed handle to a DID and
  check the list **before** starting authorization, then check again on every
  gated request.
- Callback errors come in three kinds the user needs to tell apart: handle
  not found, sign-in cancelled, sign-in expired. Show one plain sentence on
  the login page and scrub `?error=` after showing it.
- Test sign-in by navigating in a real browser, not with curl. A `302`
  from the start endpoint does not prove that the browser follows it:
  `form-action` CSP can block the cross-origin hop.

## verify

- Sign in end to end in a real browser against a real PDS, including a
  cancel and an expired state.
- Write one record. Confirm it lands in the account's repo and that the
  appview shows it.
- Call a gated route with no token, an expired token, a token for the wrong
  `lxm`, and a token for the wrong `aud`. Each must be refused.