The authorization code is a short-lived JWT the application receives at the end of a login, and exchanges at the token endpoint for its tokens (OAuth 2.0 authorization code grant). It's issued by the authorization endpoint of the Authentication API in exchange for a consent token, and plays an internal role. See Tokens — General for how it fits in the lifecycle.
The application starts the login with an authorization request, including a PKCE code challenge (required):
GET /oauth2/authorize?response_type=code&client_id={client_id}&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=openid%20offline_access&state={state}&nonce={nonce}&code_challenge={code_challenge}&code_challenge_method=S256 HTTP/1.1Host: {tenant_id}.api.quasr.ioAfter the login, the user is redirected back to the application with the authorization code:
HTTP/1.1 302 FoundLocation: https://app.example.com/callback?code={authorization_code}&state={state}The application exchanges the code at the token endpoint, with the code verifier and its client authentication (see Applications — Browser):
POST /oauth2/token HTTP/1.1Host: {tenant_id}.api.quasr.ioContent-Type: application/x-www-form-urlencoded grant_type=authorization_code&code={authorization_code}&code_verifier={code_verifier}&client_id={client_id}openid and a refresh token if it contains offline_access. See Access.INVALID_PARAMETER (body.code); a wrong code verifier with body.code_verifier.| Claim | Description |
|---|---|
sub | The ID of the account. |
client_id | The ID of the application the code is issued to. |
scope | The granted scopes. |
nonce | The nonce of the authorization request, if any, passed on to the identity token. |
iss | The issuer, i.e. your tenant: https://{tenant_id}.api.quasr.io. |
aud | The audience: https://api.quasr.io. |
iat / nbf / exp | When the token was issued, is valid from and expires (5 minutes). |
jti | The unique ID of the token. |
https://api.quasr.io/claims/typ | The token type: oauth2:code. |
https://api.quasr.io/claims/rst | The response type of the authorization request, e.g. code. |
https://api.quasr.io/claims/ccv | The PKCE code challenge (encrypted for the plain method). |
https://api.quasr.io/claims/ccm | The PKCE code challenge method: S256 or plain. |
https://api.quasr.io/claims/clm | The granted claims, from the consent token. |
https://api.quasr.io/claims/atr | The IDs of the attributes to include in the identity token, from the consent token. |
https://api.quasr.io/claims/ata | The IDs of the attributes to include in the access token, from the consent token. |
https://api.quasr.io/claims/max | The latest moment the resulting tokens can expire, from the consent token. |
https://api.quasr.io/claims/use | How often the token can be used: 1 (once). |
https://api.quasr.io/claims/ipb | Whether the code is bound to the IP address in ipa. |
https://api.quasr.io/claims/ipa | The IP address the code was issued to. |
https://api.quasr.io/claims/ten | The ID of the tenant. |
An example authorization code:
{ "client_id": "{client_id}", "scope": "openid offline_access", "nonce": "{nonce}", "sub": "{account_id}", "jti": "{token_id}", "aud": "https://api.quasr.io", "iss": "https://{tenant_id}.api.quasr.io", "iat": 1767225600, "nbf": 1767225600, "exp": 1767225900, "https://api.quasr.io/claims/typ": "oauth2:code", "https://api.quasr.io/claims/rst": "code", "https://api.quasr.io/claims/ccv": "{code_challenge}", "https://api.quasr.io/claims/ccm": "S256", "https://api.quasr.io/claims/clm": [ "email" ], "https://api.quasr.io/claims/atr": [ "{email_attribute_id}" ], "https://api.quasr.io/claims/ata": [], "https://api.quasr.io/claims/max": 2082801600, "https://api.quasr.io/claims/use": 1, "https://api.quasr.io/claims/ipb": false, "https://api.quasr.io/claims/ipa": "203.0.113.42", "https://api.quasr.io/claims/ten": "{tenant_id}"}Authorization codes are configured per application (see Applications — Configuration):
config.tokens.code.enc) - Whether the code is encrypted, so its content can only be read by Quasr. Enabled by default.config.tokens.code.ipb) - Whether the code can only be exchanged from the IP address it was issued to. Disabled by default.The lifetime (5 minutes) and usage (once) of authorization codes are fixed.