# 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.

- URL: https://iamops.dev/access-refresh-id-tokens-explained/
- Language: en
- Author: Argo
- Published: 2026-11-23
- Category: Knowledge
- Depth: Explainer
- Audience: Security leaders and architects
- Time: 5 min
- Topics: OAuth, OpenID Connect, Tokens, JWT, Basics

## TL;DR

- An [access token](https://iamops.dev/access-refresh-id-tokens-explained/#access-token-what-the-api-checks) is what an application programming interface (API) checks before it answers. It is short-lived and meant for the API, not for the app to read.
- A [refresh token](https://iamops.dev/access-refresh-id-tokens-explained/#refresh-token-getting-a-new-one) quietly gets new access tokens, so it is more valuable than an access token and must be guarded harder.
- An [identifier (ID) token](https://iamops.dev/access-refresh-id-tokens-explained/#id-token-who-signed-in) tells the app who signed in. It belongs to OpenID Connect and should never be sent to an API as a pass.
- Most bugs come from [mixing them up](https://iamops.dev/access-refresh-id-tokens-explained/#common-mix-ups-that-cause-bugs), and a stolen token is a reason to read [what Demonstrating Proof of Possession (DPoP) does about it](https://iamops.dev/dpop-par-rar-explained/).

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

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.

<abbr title="Open Authorization">OAuth</abbr> 2.0 (the standard for [delegated access](https://iamops.dev/oauth-token-exchange-delegation-impersonation/)) and OpenID Connect (<abbr title="OpenID Connect">OIDC</abbr>, 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 <abbr title="JSON Web Token">JWT</abbr>. They do different jobs. This page is based on the <abbr title="Request for Comments">RFC</abbr> 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.](https://iamops.dev/img/access-refresh-id-tokens-explained.svg)

*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 [<abbr title="Model Context Protocol">MCP</abbr> server lab](https://iamops.dev/mcp-server-no-token-passthrough/) 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 <abbr title="identifier">ID</abbr> 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

- How a token can be tied to a key so a stolen copy is useless: [<abbr title="Demonstrating Proof of Possession">DPoP</abbr>, <abbr title="Pushed Authorization Requests">PAR</abbr> and <abbr title="Rich Authorization Requests">RAR</abbr> explained](https://iamops.dev/dpop-par-rar-explained/).
- How an agent trades one token for a narrower one: [OAuth token exchange for AI agents](https://iamops.dev/oauth-token-exchange-delegation-impersonation/).
- A lab where an API checks audience and refuses passthrough: [protecting an <abbr title="Model Context Protocol">MCP</abbr> server with OAuth](https://iamops.dev/mcp-server-no-token-passthrough/).
- What happens when a sign-in code is phished: [device code phishing and AI agents](https://iamops.dev/device-code-phishing-ai-agents/).

## Sources

- [IETF, RFC 6749, The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749)
- [OpenID Foundation, OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html)
- [IETF, RFC 7519, JSON Web Token (JWT)](https://www.rfc-editor.org/rfc/rfc7519)

Discuss: [X](https://x.com/iamopsdev) | [LinkedIn](https://www.linkedin.com/company/iamops-dev/)
