https://<name>.auth.didit.mefor a live application,https://<name>.sandbox.auth.didit.mefor a sandbox application,- or your own custom domain, once it is active.
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.Discovery and keys
The issuer supports:
- Response type
codeand response modequery. - Grant types
authorization_codeandrefresh_token. - PKCE method
S256only. Clients are public: there is no client secret, andclient_idis your application ID. - Signing algorithm
ES256(P-256 keys). - Scopes
openid,email,phone,profileandoffline_access.
prompt=none is not supported. Use GET /session/ to read and check a session.
Caching and rotation
Both documents answerCache-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 withk_. Every token names its key in thekidheader. - 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 akidyou 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 theauthorization_endpoint:
The quickstarts build this request for you.
Exchange the code
The callback receivescode 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 headeralg: 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:algisES256andtypisat+jwt. Reject every other algorithm, includingnone.- The
kidis in your application’s JWKS, and the signature verifies. issequals your configured issuer, andaudequals your application ID.expandiatare valid, allowing up to 60 seconds of clock difference, andsub,sidandjtiare present.actisnull. An AI agent’s access token is signed with the same key and carries the sametyp,issandaud; onlyacttells it apart. Reject it, unless the endpoint accepts agents: then allow only whatact.scopesgrants.GET /session/always rejects an agent’s token.
GET /session/.
Check the session
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
- 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 failsGET /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
400or 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
429before the refresh runs, so retry it afterRetry-After. The token endpoint allows 30 requests a minute and 300 an hour per IP address. On top of that, everyPOSTandDELETEof 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 otherPOSTandDELETE(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) oridle_timeout(default 1 day), - the person signs in again while multiple sessions are off,
- the person resets their password while
revoke_on_password_changeis 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.