CodeOath
← All posts
Auth & Security60 min total · 19 parts

OAuth 2.0 and JWT Explained: How "Login with Google" Actually Works

Contents — Part 12 of 19: Access Tokens vs. Refresh Tokens vs. ID Tokens
Part 12 of 19 · ~1 min

Access Tokens vs. Refresh Tokens vs. ID Tokens

Three different token types show up around any real OAuth/OIDC integration, and mixing up their purpose is a common source of bugs.

TokenPurposeTypical lifetimeSent to
Access tokenProves you're allowed to call an API; sent with every API requestShort (minutes to a couple of hours)The resource server (the API)
Refresh tokenUsed to obtain a new access token without re-authenticating the userLong (days to months); revocable server-sideOnly your own backend's token endpoint — never a resource server
ID token (OIDC)A JWT specifically asserting who the user is — this is the "authentication" half of the pictureShort; typically consumed once at loginYour own application, to establish a local session

A subtlety worth calling out explicitly: an access token is meant to be opaque to the client — your frontend shouldn't need to (and often structurally can't, if the authorization server issues opaque reference tokens rather than JWTs) parse it to learn anything. An ID token, by contrast, is meant to be read by your application — it's a self-contained, verifiable statement of identity your own backend decodes to learn who just logged in and create a session. Sending an access token to an API that expects an ID token (or vice versa) is a real, recurring integration bug, precisely because both are frequently JWTs and look superficially identical.