Skip to main content
Authentication is new. Every call on this page uses end-user credentials or none at all. Never send your verification API key or a console token to these endpoints.
Each application is its own OpenID Connect issuer. The issuer is your application’s sign-in origin:
  • https://<name>.auth.didit.me for a live application,
  • https://<name>.sandbox.auth.didit.me for a sandbox application,
  • or your own custom domain, once it is active.
Live and sandbox are separate issuers with separate keys. Set DIDIT_AUTH_ISSUER to your issuer, without a trailing slash, and DIDIT_APPLICATION_ID to your application ID: tokens carry it as aud. Your publishable key encodes the issuer: after pk_live_ or pk_test_, it is the issuer in unpadded base64url.
When your custom domain becomes active, it replaces the default host as the issuer. New tokens name it in iss, discovery points jwks_uri at it, and your publishable key changes. Access tokens issued under the default host then fail GET /session/ until they are refreshed. Update DIDIT_AUTH_ISSUER when you activate the domain, or accept both issuers until the older tokens expire, within 5 minutes.
The server endpoints on this page (discovery, keys, tokens and the session) are in the Authentication API reference, generated from openapi-authentication.json. The hosted sign-in page is not.

Discovery and keys

The issuer supports:
  • Response type code and response mode query.
  • Grant types authorization_code and refresh_token.
  • PKCE method S256 only. Clients are public: there is no client secret, and client_id is your application ID.
  • Signing algorithm ES256 (P-256 keys).
  • Scopes openid, email, phone, profile and offline_access.
There is no userinfo, introspection or end-session endpoint, and prompt=none is not supported. Use GET /session/ to read and check a session.

Caching and rotation

Both documents answer Cache-Control: public, max-age=300, so you and shared caches can keep them for 5 minutes. They allow 1,200 requests a minute and 12,000 an hour per IP address, far above the sign-in endpoints, because many backend instances often share one address.
  • Each key has a kid; new key IDs start with k_. Every token names its key in the kid header.
  • Keys rotate every 30 days. Didit publishes the next key one day before it starts signing, and keeps the previous key published for one day after it stops. A JWKS cached for 5 minutes therefore keeps verifying across a rotation.
  • Cache keys by kid. When a token names a kid you do not have, fetch the JWKS again, at most once a minute, and reject the token if the key is still missing.
  • When Didit revokes a compromised key, it removes the key from the JWKS at once, and GET /session/ rejects every token the key signed. A replacement key starts signing immediately, without the day of advance publication. A JWKS cached up to 5 minutes earlier still accepts the revoked key and does not know the replacement yet, so new tokens can fail offline verification until the cache refreshes.

Start sign-in

Open the hosted page, which is the authorization_endpoint:
The quickstarts build this request for you.

Exchange the code

The callback receives code and state. Check state, then exchange the code within 60 seconds. Each code works once. The body can be JSON or form-encoded.
expires_in counts the seconds the access token has left. When you turn off multiple sessions, this exchange ends the person’s other sessions.

Access token claims

The access token is a JWT with header alg: ES256 and typ: at+jwt. It lasts at most 5 minutes, and never longer than its session. The ID token has header typ: JWT. It carries the same claims except client_id, plus auth_time and email_verified, and email, name and phone_number when they have a value. Only the ID token from the code exchange carries nonce, when the sign-in had one: check it there, because ID tokens from a refresh never carry it. An ID token is never accepted as an access token.

Verify a token on your server

Check all of these before you trust a claim:
  1. alg is ES256 and typ is at+jwt. Reject every other algorithm, including none.
  2. The kid is in your application’s JWKS, and the signature verifies.
  3. iss equals your configured issuer, and aud equals your application ID.
  4. exp and iat are valid, allowing up to 60 seconds of clock difference, and sub, sid and jti are present.
  5. act is null. An AI agent’s access token is signed with the same key and carries the same typ, iss and aud; only act tells it apart. Reject it, unless the endpoint accepts agents: then allow only what act.scopes grants. GET /session/ always rejects an agent’s token.
Take the issuer from your configuration, never from the token.
Offline verification cannot see a session that ended a moment ago. When that matters, for example before a payout, call GET /session/.

Check the session

The response holds sub, sid, application_id, vendor_data, amr, mfa_verified, email, email_verified, phone, verified_identity, verified, expires_at, post_logout_redirect_uri and organizations. Each organization entry has organization_id, organization__name, role and custom_role. This check is stricter than offline verification. It also fails when the session was revoked, went idle or passed its lifetime, when the person was blocked or their email is no longer verified, when the session no longer meets your MFA policy (for example after the person added an authenticator app or became an organization admin), or when the token was replaced by a refresh. A failure returns 401 {"detail": "invalid_token"} with WWW-Authenticate: Bearer. GET /session/ allows 30 requests a minute and 300 an hour per IP address, a limit it shares with DELETE /session/. Verify tokens offline on every request, and keep this call for the moments that need it. Each successful call counts as activity, so it restarts the session’s idle_timeout. A verified email is not an identity verification. Read verified for that: here it is null when there is none, while the tokens carry {}.

Refresh tokens

A refresh returns a new access token, ID token and refresh token, and the refresh token you sent stops working.
  • The refresh token is a random string, valid until the session ends.
  • Reuse ends the session. When a used refresh token arrives again, Didit treats it as a sign of theft: it revokes the session and returns 400 {"error": "invalid_grant"}. The session’s tokens stop working too, including those from the earlier refresh: their refresh token fails and their access token fails GET /session/ at once, though it still verifies offline until it expires, within 5 minutes.
  • Run one refresh at a time for a session, across tabs, devices and server instances, and replace all three tokens together.
  • If a refresh fails with 400 or gets no answer, start sign-in again. Do not retry it blindly: a retry after a refresh that did succeed is a reuse.
  • A 503 {"error": "temporarily_unavailable"} means the refresh did not happen and your refresh token still works. Retry it with backoff.
  • Didit answers a 429 before the refresh runs, so retry it after Retry-After. The token endpoint allows 30 requests a minute and 300 an hour per IP address. On top of that, every POST and DELETE of your application shares bot protection buckets: 60 requests a minute per IP address across those endpoints and 30 a minute per device. For the whole application, refreshes have a bucket of 6,000 a minute and every other POST and DELETE (browsers and sign-in steps included) one of 3,000 a minute, so refreshes never use up your sign-ins.
  • With 5-minute access tokens, 300 refreshes an hour cover about 25 people who stay active. If your server refreshes for many people from one address, refresh only when a request needs a new token, and refresh in the browser or app where you can.

Sign out

DELETE /session/ with the person’s current access token ends the session and returns 204. Its refresh token stops working, and its access tokens fail GET /session/ at once; tokens you verify offline stay valid until they expire. Then send the person to your post_logout_redirect_uri, if you set one. Sign-out needs an access token that GET /session/ would accept: one that has not expired and has not been replaced by a refresh. A 401 means the session did not end. Refresh, then sign out with the new access token; if the refresh fails with 400, the session can no longer be used. A session also ends when:
  • it passes session_lifetime (default 30 days) or idle_timeout (default 1 day),
  • the person signs in again while multiple sessions are off,
  • the person resets their password while revoke_on_password_change is on,
  • your team revokes it or blocks the person in the console,
  • a used refresh token is sent again.

Lifetimes

Store credentials by purpose

  • Keep verification API keys and console tokens on your server.
  • Keep browser access tokens in memory where possible. For server-rendered apps, use secure HttpOnly cookies and protect cookie-authenticated requests against CSRF.
  • Store mobile refresh tokens in platform-protected storage. Clear local state after sign-out.
  • Never put tokens in URLs or logs.
Continue with the JavaScript quickstart, the Next.js quickstart or the Authentication API reference.
Last modified on November 3, 2026