Token Endpoint: Code Exchange and Refresh | Didit Authentication API
POST /token/ exchanges a PKCE authorization code or rotates a refresh token. Reusing a refresh token revokes the session.
https://<name>.auth.didit.me, and never take your Didit API key.Body
- Authorization code grant
- Refresh token grant
One of the two grants, chosen by grant_type. The endpoint accepts the fields of both grants and validates every field it receives, so a refresh that also carries a malformed code_verifier gets a field error. Send only your grant's fields; any other field gets unknown_field.
authorization_code The code query parameter your redirect_uri received. Check the callback's state before you exchange it.
128"Vb0bVt4CLlr8ZL0kE5mAxv8gS6R0rW3hYqC1pN7dJ2s"
The PKCE verifier whose S256 hash was the sign-in's code_challenge.
43 - 128^[A-Za-z0-9._~-]{43,128}$"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
The exact redirect_uri the sign-in started with. It must still be one of the application's redirect URIs.
2048"https://app.example.com/auth/callback"
Optional. When sent, it must equal your application ID, or the request fails with invalid_client.
64"7b0a6c2e-3f41-4c9a-8d55-1e2f3a4b5c6d"
Optional and accepted from standard OpenID Connect clients. It never widens what the sign-in granted.
512"openid email"
Response
New tokens for the session.
Tokens for one session. Replace all three together after a refresh.
ES256 JWT, header typ: at+jwt. Send it as Authorization: Bearer <access_token>. Claims: AccessTokenClaims.
"eyJhbGciOiJFUzI1NiIsImtpZCI6ImtfOHNKMmRRdlgwbkxyNVRmWWIzSGtQdyIsInR5cCI6ImF0K2p3dCJ9.eyJpc3MiOiJodHRwczovL3lvdXItYXBwLmF1dGguZGlkaXQubWUiLCJhdWQiOiI3YjBhNmMyZS0zZjQxLTRjOWEtOGQ1NS0xZTJmM2E0YjVjNmQiLCJzdWIiOiIxYzlkOGI4OC0xYmZmLTQzZDEtYWQ3YS04OGIyYmMwMDI0ZTkiLCJzaWQiOiJjOWFiZjZjYy0yZDY0LTRiZjItYjMxZS1hNGQwOWEwNzBhYjEiLCJqdGkiOiJSZ3F1NzE3OWUtbGhKMGJ2VmVELVlnIiwiaWF0IjoxNzkyMjMzNjc0LCJleHAiOjE3OTIyMzM5NzQsInZlbmRvcl9kYXRhIjoidXNlci00MiIsIm9yZyI6bnVsbCwidmVyaWZpZWQiOnt9LCJhbXIiOlsicGFzc3dvcmQiXSwiYWN0IjpudWxsLCJjbGllbnRfaWQiOiI3YjBhNmMyZS0zZjQxLTRjOWEtOGQ1NS0xZTJmM2E0YjVjNmQifQ.AxrqN8Pm-Op-3OayZk8HcvlFQZhozRiOvQ0SgQsGgrz4UNeJlUEeSlq9B8WcYUuM8naRaY5kQt_TUofnsYcyYQ"
ES256 JWT, header typ: JWT, for your application to read who signed in. Never send it as an access token. Claims: IDTokenClaims.
"eyJhbGciOiJFUzI1NiIsImtpZCI6ImtfOHNKMmRRdlgwbkxyNVRmWWIzSGtQdyIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3lvdXItYXBwLmF1dGguZGlkaXQubWUiLCJhdWQiOiI3YjBhNmMyZS0zZjQxLTRjOWEtOGQ1NS0xZTJmM2E0YjVjNmQiLCJzdWIiOiIxYzlkOGI4OC0xYmZmLTQzZDEtYWQ3YS04OGIyYmMwMDI0ZTkiLCJzaWQiOiJjOWFiZjZjYy0yZDY0LTRiZjItYjMxZS1hNGQwOWEwNzBhYjEiLCJqdGkiOiJNTHRPNHM4SHItQnJrcDd2NTlPV0Z3IiwiaWF0IjoxNzkyMjMzNjc0LCJleHAiOjE3OTIyMzM5NzQsInZlbmRvcl9kYXRhIjoidXNlci00MiIsIm9yZyI6bnVsbCwidmVyaWZpZWQiOnt9LCJhbXIiOlsicGFzc3dvcmQiXSwiYWN0IjpudWxsLCJhdXRoX3RpbWUiOjE3OTIyMzM2NzQsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJlbWFpbCI6InBlcnNvbkBleGFtcGxlLmNvbSIsIm5vbmNlIjoibi0wUzZfV3pBMk1qIn0.avhfDFp_aUV5_1ssYzwDcIA7H6Waf19P0bn5GCg25FhLIZBGIlwc8HiUPGj1j26r21OkP4FQnS_jM1Ho3dHtKQ"
Single-use. It is valid until the session ends, and each refresh returns a new one.
"N4yZTl6y24YKYq77X_SOrBn1q2Lit81WBQMOay7dq_IVfTnxyY8ZGcJk-6-fcmWW"
Bearer Seconds until the access token expires: at most 300, less when the session ends sooner.
0 <= x <= 300299
The session these tokens belong to, the same value as the sid claim.
"c9abf6cc-2d64-4bf2-b31e-a4d09a070ab1"