iamops.dev Search
Argo on X RSS feed
ENEnglish

Knowledge Explainer · 5 min Beginner

For anyone new to sign-in tokens, including managers who need the basics.

Access, refresh and ID tokens: three tokens, three different jobs

Access token, refresh token, ID token: what each one is for, who should read it, and why mixing them up causes real security bugs. One festival analogy.

Sequence diagram: the calendar app signs the user in and gets an ID token and a refresh token, calls the calendar API with an access token, is refused with 401 on a wrong audience, and renews an expired access token through the auth server with the refresh token.
TL;DRAn access token is what an application programming interface (API)…

Before you start: nothing needed. If you have seen “Bearer eyJ…” in a browser tool and wondered what it was, this page is for you.

OAuth 2.0 (the standard for delegated access) and OpenID Connect (OIDC, the sign-in layer built on top) hand your app up to three different tokens. They look alike, and many of them are the same format, a JWT. They do different jobs. This page is based on the RFC 6749 and OpenID Connect Core specs.

Picture a music festival. You show your ticket at the gate and get a wristband, and you also get a voucher that you can swap for a new wristband when the first one wears out. A staff badge on a lanyard says who you are.

Access token: what the API checks#

Sequence diagram: the calendar app, the auth server and the calendar API. The API refuses a token with the wrong audience, and the refresh token goes only to the auth server.
The token flow. Sign-in, API call, refusal and renewal, in order.

An access token is what an application sends to an API (application programming interface) to prove it may ask. The API checks it and answers. That is the whole job.

Points to know:

  • It is meant for the API. The client app should treat it as an opaque string and not build logic around what is inside.
  • It is short-lived on purpose. If it leaks, the damage window is small. The provider sets the lifetime.
  • It carries scopes, the named permissions the user agreed to.
  • The API must check that the token was issued for it, the audience, and not accept tokens meant for other APIs. The MCP server lab shows what happens when a token is passed through an MCP server.

Refresh token: getting a new one#

A refresh token lets the app get a new access token without asking the user to sign in again. It lives longer than an access token and it goes only to the authorization server, never to an API.

That makes it more valuable. Someone who steals a refresh token can keep minting fresh access tokens. Store it carefully, and prefer providers that rotate it or tie it to the client. Not every app gets one: a quiet background service often uses its own credentials instead.

ID token: who signed in#

An ID token comes from OpenID Connect, not plain OAuth. It tells the app who just signed in, how and when. It is a JWT that the app reads: the subject, the issuer, the audience and the time.

It is for the app. It is not for an API. If you send an ID token to an API as if it were a pass, you have mixed up the badge and the wristband.

Common mix-ups that cause bugs#

  • Using the ID token to call an API. APIs should reject it, and some do not.
  • Reading claims out of an access token in the client and trusting them. The API owns that format and can change it.
  • Putting a refresh token in a place a script or a log can read it.
  • An API that skips the audience check and so accepts a token meant for someone else.
  • Forgetting that a signed JWT is readable. Anyone can decode it. The signature proves it was not changed, it does not hide it.

One example#

A user opens a travel app and picks “Sign in with your work account”.

  1. The app gets an ID token and learns that Anna signed in.
  2. It gets an access token for the calendar API with the scope to read events.
  3. An hour later the access token expires and the app quietly uses the refresh token to get a new one.
  4. The calendar API only ever sees the access token.

If Anna leaves the company, the right fix is for the provider to stop honoring the refresh token. That is why refresh tokens matter more than they look.

Where to go next#

Sources#

Discuss this on X or LinkedIn

Follow on X

New posts by email

One email a week with new posts and labs. Unsubscribe anytime.

Your address is stored with Kit, which sends the emails. Details

Related research and labs

Type to search every page. Use the arrow keys to move through the results.

    Open the full search page