Docs / Reference

Stable

Atmosphere Login SDK reference

Browser attributes, helper methods, server verifier exports, callback parameters, token claims, and common verifier errors.

Use /atmosphere-login.js to render the button or build picker URLs.Use /atmosphere-login-server.js to fetch JWKS and verify selection tokens.Selection token claims are short-lived, audience-bound, and replay-resistant.

Browser

Static browser SDK

GET/atmosphere-login.js

Enhances [data-atmosphere-login] buttons and exposes window.AtmosphereLogin helpers.

AttributeTypePurpose
data-atmosphere-loginbooleanEnhance this element as a Continue with Atmosphere button.
data-client-idURLRegistered app client ID and selection-token audience.
data-return-uriURLExact callback receiving the selection token.
data-scopestringOptional picker context. App OAuth scopes are still separate.
data-statestringOptional caller-provided nonce. If omitted, SDK generates one.
data-moderedirect | popupRedirect is the default and most reliable flow. Popup mode dispatches atmosphere-login:complete after origin, client, and state checks pass.
data-app-namestringFallback label/accessibility context.
data-app-homepageURLFallback local metadata; registered metadata wins in picker identity.
data-atmosphere-originURLUse a non-production Atmosphere deployment during local development.
Browser helpers
const built = AtmosphereLogin.buildUrl({
  clientId: "https://app.example.com/oauth/client-metadata.json",
  returnUri: "https://app.example.com/auth/atmosphere/selected",
  scope: "atproto",
});

AtmosphereLogin.continueWithAtmosphere({
  clientId: "https://app.example.com/oauth/client-metadata.json",
  returnUri: "https://app.example.com/auth/atmosphere/selected",
});

const selection = AtmosphereLogin.consumeSelection({
  clientId: "https://app.example.com/oauth/client-metadata.json",
  expectedState: stateFromSession,
});

// By default, consumeSelection removes Atmosphere Login callback parameters
// from the address bar after reading them. Pass { clearUrl: false } only if
// your router needs to control URL cleanup itself.
//
// In popup mode, the callback page also posts the selection to window.opener.
// The opener SDK dispatches "atmosphere-login:complete" after validating the
// message origin, client ID, and state.

Server verifier

GET/atmosphere-login-server.js

ES module helper for server-side callback verification in Deno, Node-compatible runtimes, and examples.

ExportPurpose
fetchAtmosphereLoginPublicJwkForToken(token, origin)Fetches the public key whose kid matches the returned selection token. JWKS is cached briefly and refreshed on key miss.
fetchAtmosphereLoginPublicJwk(origin)Fetches a public key from /oauth/jwks.json; pass { kid } when selecting explicitly. Supports { cache: false } and { cacheTtlMs }.
verifyAtmosphereLoginCallback(options)Reads callback params and verifies the embedded selection token.
verifyAtmosphereSelectionToken(options)Verifies a raw selection token against a JWK and expected claims.

Picker request parameters

ParameterRequiredMeaning
client_idYesRegistered app client ID.
return_uriYesExact callback URL for the selection token.
stateYesApp nonce returned in params and token claims.
scopeNoPicker context; not an app OAuth grant.

Callback payload

Query parameters
selection_token=eyJ...
client_id=https://app.example.com/oauth/client-metadata.json
state=generated-state
did=did:plc:...
handle=alice.example
iss=https://login.atmosphereaccount.com
Token claimMeaning
issAtmosphere deployment that signed the token.
audRegistered app client ID.
subSelected ATProto account DID.
handleSelected account handle at selection time.
pds_urlOptional known host/PDS hint.
return_uriCallback URL the token was delivered to.
stateApp nonce.
app_namePicker app identity shown to the user.
iat / expShort token lifetime.
jtiReplay key.

Verifier errors

ErrorUsually means
missing selection_tokenThe callback URL is wrong or the picker did not complete.
client_id parameter mismatchThe callback does not match the expected app.
state parameter mismatchThe app lost or changed the initiating nonce.
invalid signatureThe token is malformed or signed by the wrong key.
issuer mismatchThe expected Atmosphere deployment is wrong.
audience mismatchThe token was not minted for this app client ID.
return URI mismatchThe callback does not match the token claim.
replayed tokenThe jti has already been used.
On this page

Next steps

Keep building