What a claim is
A claim is one piece of information about a user or a token, written as a name and a value in a JSON object. "email_verified": true is a claim. ID tokens, JWT access tokens and UserInfo responses are all sets of claims.
Some claims describe the token itself: who issued it, who it is for, when it expires. Others describe the user: a name, an email address, a locale. The names are short on purpose, because tokens travel in headers and URLs.
Standard names let a client read any provider’s tokens the same way. OpenID Connect Core 1.0 defines the ID token claims and a set of standard profile claims. JWT itself (RFC 7519) defines a few general ones, and RFC 9068 defines how JWT access tokens use them.
Claims in the ID token
The ID token is the proof of sign-in that OpenID Connect adds to OAuth. OpenID Connect Core section 2 lists its claims. A client must validate several of them before it trusts the token.
| Claim | Meaning | What the client checks |
|---|---|---|
iss | The issuer. | Equals the expected issuer exactly. |
sub | A stable id for the user at this issuer. | Use with iss as the user’s key. |
aud | Who the token is for. | Contains your client id. |
exp | Expiry time in seconds since 1970. | Is in the future. |
iat | When the token was issued. | Is not unreasonably old. |
nonce | The nonce from the authorization request. | Equals the value you stored. |
auth_time | When the user last really signed in. | Fits your max_age, if you sent one. |
azp | The client the token was issued to. | Equals your client id when present. |
acr, amr | How strongly and by which methods the user signed in. | Meets your policy, if you have one. |
Two more claims bind the ID token to other values. at_hash is a hash of the access token, and c_hash a hash of the code in the hybrid flow. sid names the session at the issuer and is used by the logout specifications.
Validating an ID token with its claims
OpenID Connect Core section 3.1.3.7 lists the checks a client makes before it trusts an ID token from the code flow. Most libraries do them for you, but it helps to know what they are when one fails.
- Verify the signature with a key from the issuer’s
jwks_uri, using the algorithm you expect. - Check that
issequals the issuer you configured, exactly. - Check that
audcontains your client id. If it holds several audiences, checkazpas well. - Check that
expis in the future, allowing a small clock skew. - Check that
nonceequals the value you stored before the redirect. - If you sent
max_age, check thatauth_timeis recent enough.
Only after these checks pass should the client read sub and the profile claims.
Standard profile claims and their scopes
OpenID Connect Core section 5.1 defines the standard claims about the user. Section 5.4 groups them under four scopes. A client asks for a group by adding its scope to the authorization request.
| Scope | Claims |
|---|---|
profile | name, family_name, given_name, middle_name, nickname, preferred_username, profile, picture, website, gender, birthdate, zoneinfo, locale, updated_at |
email | email, email_verified |
address | address (an object with formatted, street_address, locality, region, postal_code, country) |
phone | phone_number, phone_number_verified |
Asking for a scope does not guarantee every claim. A provider returns the claims it has and the user agreed to share. A user without a phone number simply has no phone_number claim.
Claims in access tokens
OAuth does not say what an access token looks like. Many servers, Keycloak among them, issue JWT access tokens, and RFC 9068 describes a common profile for them. Besides iss, sub, aud, exp, iat and jti, it uses client_id for the client and scope for the granted scopes as a space-separated string.
Two more claims come up often. cnf binds a token to a key; with DPoP (RFC 9449) it holds jkt, the thumbprint of the client’s public key. act appears after a token exchange (RFC 8693) and names the party acting for the subject.
An API should read the access token’s claims, not the ID token’s. The ID token is for the client; the access token is for the API.
Claims Keycloak adds
Keycloak adds claims through client scopes and the protocol mappers inside them. These are the ones you will see in a default setup:
typ: the kind of token, such asBearerfor access tokens,IDfor ID tokens andRefreshfor refresh tokens.realm_access: the user’s realm roles, as{ "roles": [...] }, from therolesclient scope.resource_access: the user’s client roles, keyed by client id, also from therolesclient scope.allowed-origins: the client’s web origins, from theweb-originsclient scope.azp: the client id that requested the token.
Since Keycloak 25, sub and auth_time come from the basic client scope. A groups claim is not standard; Keycloak adds it only with a Group Membership mapper or the microprofile-jwt client scope.
{
"iss": "https://auth.example.com/realms/acme",
"sub": "1f8f4b3a-sample",
"aud": "account",
"exp": 1900000300,
"iat": 1900000000,
"typ": "Bearer",
"azp": "web-app",
"scope": "openid profile email",
"realm_access": { "roles": ["user"] },
"preferred_username": "alice"
}What this reference does
The reference lists every claim above with its type, meaning, the scope that asks for it and the specification that defines it. You can search by name or by any word in the meaning, and narrow the list to ID token, profile, JWT, access token or Keycloak claims.
A second panel maps each standard scope to the claims it requests. It is a reference, not a decoder: to read the claims in a real token, paste it into the JWT decoder.
How to use it
- Type a claim name, such as
auth_time, or a word, such astimeorrole. - Pick a group to narrow the list.
- Read the meaning, type and scope of each claim.
- Check the scope panel to see which scope to add to your request for the claims you need.
Choosing claims by app type
Web apps and single-page apps
Ask for openid and only the scopes you show on screen, usually profile and email. Read the user’s details from the ID token or UserInfo, and key your user records on iss plus sub.
APIs
Authorize from the access token: aud, scope and, in Keycloak, realm_access and resource_access. Do not accept an ID token as an access token.
Machine-to-machine clients
A client credentials token describes the client, not a person. In Keycloak its subject is the client’s service account, and its roles are the service account’s roles.
Why a claim is missing
- The scope was not requested, or the user did not grant it.
- The user has no value for it, such as a missing phone number.
- In Keycloak, no mapper adds it, or the mapper is not set to add it to this token type. Mappers have separate switches for the ID token, the access token and UserInfo.
- The client scope that holds the mapper is not assigned to the client, or is optional and was not requested.
- You are reading the wrong token: an ID token claim will not appear in the access token unless a mapper puts it there.
Mistakes to avoid
- Using
emailorpreferred_usernameas the user’s key. Both can change, and an address can be reused. Useisswithsub. - Trusting
emailwithout checkingemail_verified. - Skipping
audchecks, which lets a token meant for another client or API work in yours. - Reading claims without verifying the signature first.
- Putting large or private data into tokens. Tokens travel with every request and are readable by anyone who holds them.
RFC 9700 recommends access tokens that are restricted to one audience. Checking aud is how an API enforces that.