ID tokens and access tokens
When the collage app asks for sign-in and photo access in one request, the tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. response can contain two tokens side by side. Both may be JWTs, both come from the same token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect., and both are called tokens. They are meant for different readers, and many mistakes with OpenID ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. begin by mixing them up. This lesson reads each one and follows where it may go.
Reading an ID token
An ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs. is always a JSON Web TokenA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing., the format Inside a JWT took apart. Here is the one the photo service issues when Ava signs in to the collage app, decoded so that its parts can be read. All domains, identifiers and tokens in these examples are fictional.
Header
{
"alg": "RS256",
"kid": "photos-rs-2026-09",
"typ": "JWT"
}
Claims
{
"iss": "https://auth.photos.example",
"sub": "user-2048",
"aud": "photo-collage",
"exp": 1790845500,
"iat": 1790845200,
"auth_time": 1790845185,
"nonce": "demo-nonce-3"
}iss is the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts., the photo service's exact name. sub, the subject, identifies Ava's account at the photo service. It is the provider's stable identifier for her, and together with the issuer it is how the collage app will recognize her next time. aud, the audience, is the collage app's client ID, photo-collage. The token is addressed to the collage app and to no one else.
iat and exp record when the token was issued and when it stops being acceptable, five minutes later at 09:05 UTC on 1 October 2026. auth_time records when Ava actually authenticated, at 08:59:45, fifteen seconds before the token was issued. The two can be far apart. Had the photo service relied on a sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. from earlier in the day, auth_time would show that earlier time. nonce is a value the collage app generated for this sign-in attempt and sent in its request, so the token can be matched to that attempt. State and nonce explains how.
The header says the token was signed with RS256, using the photo service's key photos-rs-2026-09. As Digital signatures explained, those are hints for choosing among keys the collage app already trusts. Until the signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. has been verified and the claims checked, none of these values can be relied on. Validating an ID token and the lessons after it cover each check.
Notice what is missing. There is no name, email address or scope. This ID token reports an authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. event. Profile information can arrive in other ways, which the lessons from Standard and custom claims onward describe, and some providers add a few profile claims to the ID token as well.
Two tokens, two audiences
The access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. in the same response is addressed to the photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests.. In the OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. lessons, the printer carried its access token to api.photos.example without needing to understand it, and the collage app does the same. It might be a JWT or an opaque string, and its format is a matter between the photo service and its API.
| ID token | Access token | |
|---|---|---|
| Who it is for | The collage app, named in aud. | The photo API. |
| What it says | Who authenticated, when, and for which request. | What access the holder has been granted. |
| Who checks it | The collage app, when Ava signs in. | The photo API, on every request. |
| Where it goes next | Nowhere. The collage app reads it and starts a session. | In the Authorization header of API requests. |
| Format | Always a JWT, usually typed JWT. | Whatever the provider and API use. As a JWT, typed at+jwt. |
Each token is acceptable only to its own reader. Signing someone in with an access token is the shortcut that From delegated access to sign-in warned against. The reverse is just as wrong. If the collage app sent the ID token to the photo API as a bearer token, a careful API would reject it: the audience names the collage app, not the API, and an API that accepts JWT access tokens checks that the token is typed as an access token, as Token formats and validation explains. An API that skipped those checks would let any application holding one of Ava's ID tokens act with her access.
Statement about one sign-in
- Who it is for
- The collage app, named in aud
- Type
- JWT
- Who checks it
- The collage app, when Ava signs in
- Where it goes next
- Nowhere
- Sent to the photo API
- Refused
Credential for an API
- Who it is for
- The photo API
- Type
- at+jwt
- Who checks it
- The photo API, on every request
- Where it goes next
- In the Authorization header
- Sent to the photo API
- Accepted
An API that skipped the audience and type checks would let any application holding one of Ava's ID tokens act with her access.
What an ID token does not do
An ID token is not a session. This one expires five minutes after it is issued, and nobody expects Ava to be signed out of the collage app at 09:05. Once the collage app has validated the token, it creates a session of its own, as Staying signed in described, with a lifetime chosen for the collage app. By then the ID token has done its job.
It is not permission. The ID token says who Ava is at the photo service. It does not say what she may do at the collage app, and it does not let the collage app read her photos.
It is not a live profile either. The token describes one moment. If Ava changes her name at the photo service tomorrow, today's token still describes the old account details, and if the collage app copies information into its own records, it has to decide when to refresh them.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Read an ID token and an access token side by side, and send each to the wrong readerTake one token response apart, compare the two tokens' audiences, types and keys, and see the photo API accept its access token and refuse the ID token.