ID token contents
{
"iss": "https://dorvis.eu/oidc",
"aud": ["your-client-id"],
"sub": "…",
"iat": 1759996400,
"exp": 1760000000,
"nonce": "9b27e0…",
"given_name": "Jānis",
"family_name": "Bērziņš",
"first_name": "Jānis",
"last_name": "Bērziņš",
"person_code": "010101-12345",
"auth_method": "smartid"
}| Field | Content |
|---|---|
given_name | First name |
family_name | Last name |
first_name, last_name | The same data for older integrations |
person_code | Latvian personal code |
auth_method | The method used, for example smartid or swedbank |
iss | Must equal https://dorvis.eu/oidc |
aud | Must contain your client_id |
exp, iat | Expiry and issue time in Unix seconds |
nonce | The value from your authorization request |
sub | OpenID Connect subject identifier |
Verifying the ID token
Libraries do this for you. If you handle the token yourself, check the signature against the JWKS keys and the iss, aud, exp and nonce fields.
import { createRemoteJWKSet, jwtVerify } from 'jose';
const jwks = createRemoteJWKSet(new URL('https://dorvis.eu/oidc/.well-known/jwks.json'));
export async function verifyIdToken(idToken, expectedNonce) {
const { payload } = await jwtVerify(idToken, jwks, {
issuer: 'https://dorvis.eu/oidc',
audience: process.env.OIDC_CLIENT_ID,
});
if (payload.nonce !== expectedNonce) throw new Error('nonce mismatch');
return payload; // given_name, family_name, person_code, auth_method
}Userinfo
The same data can be read from the userinfo endpoint with the access token. In most cases the ID token is enough.
curl https://dorvis.eu/oidc/userinfo \
-H "Authorization: Bearer $ACCESS_TOKEN"Personal code
Link the user in your system by person_code. Store and compare it in one form, for example without hyphens and spaces.
// store and compare personal codes in one form
const normalizePersonCode = (code) => code.replace(/[\s-]/g, '');Did not find the answer?
Write to us and a developer will reply.






