opyeb JWTScope

Guides · Keys and flows

Access token or ID token: two JWTs with different jobs

Updated 28 Nov 2026 · 7 min read

An OAuth 2.0 login often returns two JWTs, and they look similar: three base64url segments, a JSON payload, overlapping claim names. They are not interchangeable. The access token is a credential for a resource server. The ID token is a statement about the authentication event, addressed to the client. Using one where the other belongs is a recurring source of authorisation bugs.

The simplest way to tell them apart is the audience. An access token's aud identifies the API it may be used at, such as https://api.example.com. An ID token's aud is the client identifier, such as web-portal. A resource server that checks its own identifier against aud will therefore reject an ID token automatically, which is exactly why the check matters.

PropertyAccess tokenID token
AudienceThe resource server / APIThe client application
PurposeAuthorise API callsTell the client who authenticated
Typical claimsscope, scp, roles, client_idsub, name, email, auth_time, nonce
Validated byThe APIThe client
LifetimeMinutesMinutes to an hour, often not refreshed
FormatOpaque or JWTAlways a JWT in OIDC

What each side should validate

The API validates the access token: signature with the issuer's key, issuer in an allowlist, audience equal to its own identifier, time claims with skew, and then the scope or role required for the endpoint. It does not validate a nonce, and it should not need the user's email or name. Those belong to the client's identity layer.

The client validates the ID token: signature, issuer, audience equal to its client_id, azp if present, exp, and the nonce it sent in the authorization request. It may then use sub as the local account key and optionally email and name for display. It does not send the ID token to the API as a bearer credential.

Why mixing them is dangerous

If an API accepts ID tokens, any client registered with the same issuer can obtain an ID token for its own audience and present it. The API cannot tell which client the token was for unless it checks aud, and if it does check, the ID token fails. Accepting both kinds means accepting a token minted for a different party, which is the cross-service replay problem in another form.

The reverse mistake is also real: a client that treats access-token claims as a verified profile. Access tokens may be opaque, may omit identity claims, or may carry claims intended for the API. If the application needs the user's name, it should read the ID token it validated or call the userinfo endpoint with the access token. Guessing from the access token produces inconsistent profiles between providers.

Lifetimes and refresh

Access tokens are short-lived because they are bearer credentials presented on every call. Refresh tokens are long-lived, stored more carefully, and exchanged for new access tokens. ID tokens are usually issued once at login and are not refreshed; when the client needs fresh identity data it performs a new authentication or calls userinfo. A refresh response may include a new ID token, but the client should treat it as a new statement with its own nonce rules rather than assuming the old one is still valid.

A refresh token must be bound to the client that received it. Public clients use rotation: each refresh returns a new refresh token and invalidates the old one, and reuse of an old token is treated as compromise and revokes the family. This is one of the few places where a server-side record is unavoidable, because a JWT by itself cannot be revoked.

The at+jwt profile

RFC 9068 was written to remove the ambiguity. An access token in this profile has "typ":"at+jwt" in the header and required claims including iss, aud, exp, iat, jti, sub and client_id. It explicitly says such a token must not be accepted as an ID token. A verifier can check the type before anything else and reject a token that claims the wrong role.

Not every provider uses at+jwt, so a verifier cannot require it universally. It can, however, require an access-token-specific audience and scope, and it can reject a token whose typ is JWT but whose claims look like an ID token. Explicit type checks are cheap and make the intent readable in code.

A short decision guide

Writing these rules into the verifier configuration, rather than into comments, prevents the slow drift where a service starts accepting whatever token happens to arrive. The audience check alone removes most of the risk, and the type check removes the rest.

An ID token is a receipt for a login. An access token is a key to an API. Do not open a door with a receipt.

Sources

Questions

Can an API accept an ID token as authentication?

No. An ID token's audience is the client application, not the API. Accepting it at an API lets any client that received one call the API, and mixes identity proof with authorization. The API should accept an access token whose audience names the API.

Can a client read an access token to learn who the user is?

It can read the claims if the token is a JWT, but it should not treat them as a verified identity. Identity comes from the ID token, validated by the client, or from a userinfo endpoint. Access token claims may be minimal or opaque by design.

What is at+jwt?

RFC 9068 defines a profile for OAuth 2.0 access tokens in JWT form. It requires the typ header to be at+jwt, a jti, iss, aud, exp, iat, sub and client_id, and it forbids using such a token as an ID token. Its purpose is to make the two kinds of token distinguishable.

Decode both tokens from a login and compare aud, azp and the claim sets side by side.

Open the verifier

Written against the JOSE specifications (RFC 7515–7519), RFC 7636 and RFC 8037; every example can be reproduced in the verifier linked above.

Back to the guides