Token request and response in the OIDC interface
A token request can be sent after the user has identified themselves and the e-service has received an authorization code in response to the identification request. The e-service uses the token request to replace the authorization code with personal data by calling the token endpoint from the server side (back-channel call, not through a browser).
Successful processing of the token request requires that the e-service prove its identity with a signed client assertion, which has been generated using the private key of the e-service. This mechanism (private_key_jwt) replaces the use of the traditional client secret and improves the security of identification.
Prerequisites to be met before making a token request:
- The e-service has an asymmetric key pair for signing a client assertion
- The e-service has received an authorization code (code) in connection with the response to the identification request
- The redirect address (redirect_uri) is the same as the redirect address in the identification request
The identification request is sent to the token endpoint, which has been specified in the OICD metadata of Suomi.fi e-Identification.
In the test environment, the metadata can be found at https://testi.apro.tunnistus.fi/.well-known/openid-configuration
In production, the metadata can be found at https://tunnistautuminen.suomi.fi/.well-known/openid-configuration
The request is made using the HTTP POST method and the parameters are sent in the request body format `application/x-www-form-urlencoded. The request must not be made through a browser (front-channel) but only from one server to another (back-channel) so that the client_assertion and the authorization code do not end up in the browser's history or logs.
POST parameter | Example value | Description |
|---|---|---|
client_assertion_type | urn:ietf:params:oauth:clie | The type of client assertion |
client_assertion | eyJraWQiOiJzaWdfRUNfa2 | Client assertion A signed JWT identifier used by the e-service to prove its identity. |
grant_type | authorization_code | Describes how personal data is requested. Suomi.fi e-Identification uses only `authorization_code`. |
code | AAlzZWNyZXQxMzX2pYELtf | The authorization code(code) received in the response to the identification request |
redirect_uri | https://testipalvelu.apro. | The return address to which the user was redirected at the end of the identification request. |
Content of the client_assertion parameter of the token request:
Header
{
"kid": "sig_EC_key_2026-06-03",
"alg": "ES256"
}
Field | Example value | Description |
|---|---|---|
kid | sig_EC_key_2026-06-03 | The identifier of the key (key id), has been used to sign the client_assertion. |
alg | ES256 | The signing algorithm of the JWT identifier. Possible values: RS256, RS512, ES256, PS256, PS512 |
Payload
{
"iss": "tunnistus_testipalvelu",
"sub": "tunnistus_testipalvelu",
"aud": "https://testi.apro.tunnistus.fi/idp/profile/oidc/token",
"exp": 1780465373,
"jti": "RitsN2WEGENzQXF_07RlkfiwaaHLkSgLOsGyS193y14"
}
Field | Esimerkkiarvo | Description |
|---|---|---|
iss | tunnistus_testipalvelu | The identifier of the JWT generator. Often the unique identifier (client_id) of the e-service. |
iss | tunnistus_testipalvelu | The unique identifier (client_id) of the e-service. |
aud | https://testi.apro.tunnistus | Specifies to which web address this token request has been directed. Must include the address of the token endpoint of Suomi.fi e-Identification. |
exp | 1780465373 | The timepoint when the validity of the JWT identifier ends, seconds since 1970-01-01T00:00:00Z UTC. |
jti | RitsN2WEGENzQXF_07Rlkfi | The unique ID of the JWT identifier. |
The response of the token interface includes the personal data signed with the public key of Suomi.fi e-Identification and encrypted with the public key of the e-service. Below is an example of response to a token request.
POST parameter | Example value | Description |
|---|---|---|
access_token | AAlzZWNyZXQxMzWP_ZatY | Not in use in Suomi.fi e-Identification, but it is returned according to the OIDC specification. Normally used with, for example, the userinfo endpoint |
scope | openid eidas | The sets of attributes (scope) included in the JWT identifier of personal data |
id_token | eyJraWQiOiJlbmNfUlNBX2 | An encrypted and signed JWT identifier containing personal data |
token_type | Bearer | The type of the JWT identifier |
expires_in | 600 | The expiry time of the JWT identifier in seconds |
Content of id token
Header
{
"kid": "enc_RSA_key_2026-07-28",
"cty": "JWT",
"enc": "A256GCM",
"alg": "RSA-OAEP-256"
}
Parameter | Example value | Description |
|---|---|---|
kid | enc_RSA_key_2026 | The id of the e-service's key, has been used to encrypt the encryption key. |
cty | JWT | The type of the content, always JWT |
enc | A256GCM | The encryption algorithm of the content |
alg | RSA-OAEP-256 | The encryption algorithm used in delivering the encryption key. |
NestedHeader
{
"alg": "RS256",
"kid": "uYjhtwbBY32VvJJ6mn6WbUPzpF02r1naZbMsvNagVTk"
}
Parameter | Example value | Description |
|---|---|---|
alg | RS256 | Signing algorithm |
kid | uYjhtwbBY32VvJJ6mn6Wb | The identifier of the signing key of Suomi.fi e-Identification. The keys can be found at the following web addresses: Test: https://testi.apro.tunnistus |
Attributes (Claims)
{
"address_fi": "Nordeatie 2",
"at_hash": "BpXJgnu3cqbf9y4AF0eyow",
"sub": "JWVRUTIL36J2Y32JYMR2DDPKS7OKXQWT",
"iss": "https://testi.apro.tunnistus.fi/",
"municipality_fi": "Helsinki",
"postoffice_fi": "Helsinki",
"sid": "_56dfd38d84dbcd1d95ea5927bc016b5b",
"acr": "urn:oid:1.2.246.517.3002.110.999",
"vtjverified": "true",
"surname": "Testaaja",
"postalcode": "00120",
"givenname": "Nordea",
"auth_time": 1785301604,
"exp": 1785305215,
"iat": 1785301615,
"municipalitycode": "019",
"address_sv": "Nordeaväg 2",
"nationalidentificationnumber": "210281-9988",
"municipality_sv": "helsingfors",
"finnishcitizenship": "1",
"postoffice_sv": "Helsingfors",
"firstnames": "Portaalia Nordea",
"nonce": "nP3LHuqmAcY_tjFceFX_7zoM6JaH-B9 pEl4maFYDRn4",
"aud": "tunnistus_testipalvelu",
"displayname": "Nordea Testaaja",
"fullname": "Testaaja Portaalia Nordea",
"protectionorder": "0"
}
The e-service must validate the id_token before using the personal data contained in it. At least the following checks should be carried out:
- Verify that the id_token has been signed with the key published by Suomi.fi e-Identification (the keys can be found at the keyset address)
- Verify that the value in the "iss" field matches the expected address of Suomi.fi e-Identification
- Verify that the value in the "aud" field corresponds to the e-service's own client_id
- Verify that the validity period in accordance with the "exp" field has not ended
- Verify that the value in the "nonce" field matches the nonce value sent in the identification request
- Decrypt the encryption by using the private key of the e-service before verifying the signature
Neglecting to perform the nonce verification exposes the e-service to replay attacks. The e-service must save the nonce value sent in the identification request and compare it with the value found in the id_token of the token response.
Attribute (Claim) | Example value | Description |
|---|---|---|
at_hash | BpXJgnu3cqbf9y4AF0eyow | The checksum of the access token. Not in use in Suomi.fi e-Identification. Normally used with, for example, the userinfo endpoint |
iss | https://testi.apro.tunnistus | The identifier of the JWT generator |
sid | _56dfd38d84dbcd1d95ea5 | The identifier of the identification event (session id). This can be used in any clarifications afterwards. |
acr | urn:oid:1.2.246.517.3002. | The level of assurance of an identification event |
auth_time | 1785301604 | The timepoint when the user identified themselves, seconds since 1970-01-01T00:00:00Z UTC |
exp | 1785305215 | The timepoint when the validity of the JWT token ends, seconds since 1970-01-01T00:00:00Z UTC. |
iat | 1785301615 | The timepoint when the JWT was generated, seconds since 1970-01-01T00:00:00Z UTC. |
nonce | nP3LHuqmAcY_tjFceFX_7z | A single-use identifier that can be used to link an identification request and a token response with each other. This is done to prevent replay attacks related to reuse of the request. The e-service is responsible for verifying that the sent identifier and the received identifier match. |
aud | tunnistus_testipalvelu | Specifies to which e-service the response has been addressed. Includes the unique identifier of the e-service (client_id) |
Errors
If the token request fails, the service returns the HTTP status code 400 and an error response in JSON format in accordance with the OAuth2 standard (RFC 6749:
{
"error": "invalid_grant",
"error_description": "..."
}
The most common error codes can be found on the Error codes page. The authorization code (code) is single-use and short-lived. If the token request is not made immediately after the response to the identification request, the code may expire before it is used.
Seuraavat vaiheet
Once the id_token has been validated and decoded, the e-service can use the personal data obtained from it to identify the user in its own system. See the more detailed descriptions of individual attributes on the page Scopes and claims.
There is no need to use the access_token separately in the case of Suomi.fi e-Identification because all the required data is obtained from the id_token.