Tokens — Authorization Code

Tokens

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.

Obtaining & Using

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.io

After 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}
  • The response contains an access token, and an identity token if the scope contains openid and a refresh token if it contains offline_access. See Access.
  • An invalid, used or expired code, or one exchanged from another IP address while IP binding is enabled, is rejected with INVALID_PARAMETER (body.code); a wrong code verifier with body.code_verifier.

Claims

Claim Description
subThe ID of the account.
client_idThe ID of the application the code is issued to.
scopeThe granted scopes.
nonceThe nonce of the authorization request, if any, passed on to the identity token.
issThe issuer, i.e. your tenant: https://{tenant_id}.api.quasr.io.
audThe audience: https://api.quasr.io.
iat / nbf / expWhen the token was issued, is valid from and expires (5 minutes).
jtiThe unique ID of the token.
https://api.quasr.io/claims/typThe token type: oauth2:code.
https://api.quasr.io/claims/rstThe response type of the authorization request, e.g. code.
https://api.quasr.io/claims/ccvThe PKCE code challenge (encrypted for the plain method).
https://api.quasr.io/claims/ccmThe PKCE code challenge method: S256 or plain.
https://api.quasr.io/claims/clmThe granted claims, from the consent token.
https://api.quasr.io/claims/atrThe IDs of the attributes to include in the identity token, from the consent token.
https://api.quasr.io/claims/ataThe IDs of the attributes to include in the access token, from the consent token.
https://api.quasr.io/claims/maxThe latest moment the resulting tokens can expire, from the consent token.
https://api.quasr.io/claims/useHow often the token can be used: 1 (once).
https://api.quasr.io/claims/ipbWhether the code is bound to the IP address in ipa.
https://api.quasr.io/claims/ipaThe IP address the code was issued to.
https://api.quasr.io/claims/tenThe 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}"}

Configuration

Authorization codes are configured per application (see Applications — Configuration):

  • Code Token Encryption (config.tokens.code.enc) - Whether the code is encrypted, so its content can only be read by Quasr. Enabled by default.
  • Code Token IP Binding (config.tokens.code.ipb) - Whether the code can only be exchanged from the IP address it was issued to. Disabled by default.
  1. 1Fixed: 5 minutes, and the code can only be used once
  2. 2On by default: only Quasr can read the code

The lifetime (5 minutes) and usage (once) of authorization codes are fixed.

Security

  • PKCE is required, so an intercepted code can't be exchanged without the code verifier.
  • A code can only be used once and expires after 5 minutes, so it isn't tracked or revocable.
2026.11.22 | © Copyright 2026 Quasr BV