Skip to main content
Developer

Token request#

View as Markdown
On this page

The token endpoint exchanges an authorisation code for an ID token that contains verified identity claims.

Endpoint#

POST /token

Request format#

Headers#

Content-Type: application/x-www-form-urlencoded

Parameters#

ParameterRequiredTypeDescription
client_idYesstringThe OAuth client identifier
client_assertion_typeYesstringMust be urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertionYesstringSigned JSON Web Token (JWT) for client authentication
grant_typeYesstringMust be authorization_code
codeYesstringAuthorisation code from the callback
code_verifierYesstringProof Key for Code Exchange (PKCE) code verifier (43-128 characters)
redirect_uriYesstringMust match the redirect_uri from the pushed authorisation request (PAR)

Example request#

POST /token HTTP/1.1
Host: {base-url}
Content-Type: application/x-www-form-urlencoded

client_id=dip_aci_your_client_id
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=eyJhbGciOiJFUzI1NiIsImtpZCI6Im15LWtleSIsInR5cCI6IkpXVCJ9...
&grant_type=authorization_code
&code=SplxlOBeZQQYbYS6WxSbIA
&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
&redirect_uri=https://client.example.org/callback

Client assertion JWT#

The client assertion authenticates the client. See Authentication for full details.

Header (3 claims exactly):

{
  "alg": "ES256",
  "kid": "my-signing-key",
  "typ": "JWT"
}

Payload (4 required claims):

{
  "iss": "dip_aci_your_client_id",
  "sub": "dip_aci_your_client_id",
  "aud": "https://{base-url}",
  "exp": 1759835872
}

Note: ID Check accepts the standard JWT claims iat, jti, and nbf, but does not require them. ID Check rejects any other claims.

Response#

Success response (200 OK)#

Response headers#

HeaderValue
Content-Typeapplication/json
Cache-Controlno-store
Pragmano-cache

Response body#

{
  "id_token": "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIiwia2lkIjoiZGlwLWVuYy1rZXkifQ...",
  "access_token": "not_applicable",
  "token_type": "Bearer",
  "expires_in": 900
}
FieldTypeDescription
id_tokenstringEncrypted JWT in JSON Web Encryption (JWE) format, which contains the signed ID token
access_tokenstringPlaceholder value. ID Check is an identity verification service where the ID token is the primary artefact.
token_typestringOAuth 2.0 token type. Always Bearer.
expires_innumberToken lifetime in seconds

Error response#

{
  "error": "invalid_request",
  "error_description": "Session expired"
}

Error codes#

ErrorHTTP statusDescription
invalid_request400Missing or invalid parameters, redirect URI mismatch, or invalid session state
invalid_grant400The session has expired
invalid_client401Client authentication failed (unknown client or invalid credentials)
not_found404Session not found for the given authorisation code
access_denied404Unauthorised session access or PKCE verification failure
server_error500Internal server error

ID token format#

The id_token is a JSON Web Encryption (JWE) that contains a signed JWT.

Encryption details#

PropertyValue
AlgorithmRSA-OAEP-256
EncryptionA256GCM
ContentSigned JWT (nested)

Decryption process#

  1. 1

    Parse the JWE

  2. 2

    Decrypt using the client's private key

  3. 3

    Extract the signed JWT from the payload

  4. 4

    Verify the JWT signature using the ID Check public key (from /jwks)

  5. 5

    Validate claims

Signed JWT details#

PropertyValue
AlgorithmES256
Typejwt

Complete ID token structure#

After decryption and signature verification, the ID token contains:

{
  "iss": "https://{base-url}",
  "sub": "hashed-pairwise-subject-identifier",
  "aud": "dip_aci_your_client_id",
  "exp": 1759839472,
  "iat": 1759835872,
  "auth_time": 1759835872,
  "jti": "e29b7c1e-6b4a-4a3b-9b1a-2f6c8a7d5e10",
  "nonce": "n-0S6_WzA2Mj",
  "acr": "urn:bankid:idcheck",
  "amr": ["face", "user"],
  "verified_claims": {
    "verification": {
      "trust_framework": "stoe",
      "evidence": [
        {
          "type": "document",
          "check_details": [
            {
              "check_method": "vcrypt",
              "result": "success"
            },
            {
              "check_method": "data",
              "organization": "id.politiet.no",
              "result": "valid"
            }
          ],
          "document_details": {
            "type": "passport",
            "document_number": "AB1234567",
            "date_of_issuance": "2020-01-15",
            "date_of_expiry": "2030-01-15",
            "issuer": {
              "country_code": "NOR",
              "name": "INNLANDET POLITIDISTRIKT"
            },
            "personal_number": "12345678901"
          }
        }
      ]
    },
    "claims": {
      "given_name": "AASAMUND SPECIMEN",
      "family_name": "OESTENBYEN",
      "birthdate": "1990-01-15",
      "gender": "male",
      "nationalities": ["NOR"]
    }
  }
}

See ID token for complete claim documentation.

Validation checklist#

After decrypting the ID token, validate the following:

ClaimValidation
issMust match the ID Check issuer URL
audMust match the client_id
expMust not be expired (current time < exp)
iatMust not be in the future
nonceMust match the nonce from the PAR request
acrShould be urn:bankid:idcheck
SignatureMust be valid using the ID Check public key

Next steps#

Was this page helpful?