SSOGEN / Learn / Access Token vs Refresh Token
Learn
Access Token vs Refresh Token
A client sends its access token, which expires in minutes, to an API on every call, and its longer-lived refresh token only to the authorization server. The server trades the refresh token for a new access token without another sign-in.

One call to the token endpoint returns both. The access token below expires in 300 seconds; the refresh token outlives it and works only at /token.
Two tokens from one response
A token endpoint returns both strings in one JSON body (RFC 6749, section 5.1). One decodes into claims. The other is an opaque reference.
{ "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6ImF0K2p3dCIs…", "token_type": "Bearer", "expires_in": 300, "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA", "scope": "invoices.read"}| Field | Example value | What a decoder shows |
|---|---|---|
typ (header) |
at+jwt |
Readable |
iss |
https://sso.acme.example |
Readable |
aud |
https://api.acme.example |
Readable: the one API it is for |
sub |
maria.lopez |
Readable |
client_id |
acme-portal |
Readable |
scope |
invoices.read |
Readable |
iat, exp |
1794992400, 1794992700 |
Readable: 300 seconds apart |
| Field | Example value | What a decoder shows |
|---|---|---|
| Value | tGzv3JOkF0XG5Qx2TlKWIA |
Hidden: no dots, no header, no claims |
| Audience | The authorization server | Hidden: not in the string |
| Client binding | The client it was issued to | Hidden: kept by the server |
| Lifetime | Set by the issuer | Hidden: no exp to read |
| Meaning | The grant behind it | Hidden: only the issuer can resolve it |
Field names follow RFC 9068; the refresh value is RFC 6749’s own example. Paste an access token into the JWT decoder and the claims appear. The refresh token will not decode, by design.
Access token vs refresh token at a glance
Audience, lifetime, storage and revocation, row by row.
| Access token | Refresh token | |
|---|---|---|
| Purpose | Call a protected API (RFC 6749, 1.4) | Get new access tokens without a sign-in (1.5) |
| Where it is sent | The API, with each request | The token endpoint only, never an API |
| Read by | The API; the client treats it as opaque | Only the server that issued it |
| Audience | One API, named in aud |
The authorization server; bound to one client (10.4) |
| Lifetime | Minutes, stated in expires_in |
Hours to days, ended earlier by an idle limit |
| Format | Often a JWT (RFC 9068) | Usually an opaque string |
| Stored where | Memory or the server session | The server session or an OS credential store |
| Revoked how | Expires at exp; introspection (RFC 7662) reports it inactive |
Revocation endpoint (RFC 7009), reuse detection or logout |
What happens when the access token expires
The client trades the refresh token for a new pair at the token endpoint.
Notice the expiry
The API answers
401, or the client seesexphas passed and refreshes before the next call.Post the refresh token
Send
grant_type=refresh_tokento the token endpoint (RFC 6749, section 6). A confidential client authenticates as well. An optionalscopemay narrow the grant, never widen it.Refresh request to the token endpoint POST /token HTTP/1.1Host: sso.acme.exampleContent-Type: application/x-www-form-urlencodedgrant_type=refresh_token&refresh_token=tGzv3JOkF0XG5Qx2TlKWIAReplace what you hold
The response carries a new access token. If it also carries a new refresh token, the client must discard the old one.
Send the person back on invalid_grant
invalid_grantmeans the refresh token is invalid, expired, revoked or issued to another client (section 5.2). Start a new sign-in.
Rotation and reuse detection in a token log
RFC 9700 (January 2025, section 4.14.2) requires public clients’ refresh tokens to rotate or be sender-constrained. With rotation, every refresh retires the old token. If a retired one comes back, the server cannot tell attacker from app, so it revokes the active token.
Example: token endpoint, illustrative values. Addresses are from the RFC 5737 documentation ranges.
| Time (UTC) | Client | Refresh token | Result | Reading |
|---|---|---|---|---|
| 09:05:01 | 198.51.100.20 | RT1 | Success | The app refreshes; it receives RT2 and RT1 is retired |
| 09:10:02 | 198.51.100.20 | RT2 | Success | RT3 issued; RT2 retired |
| 09:12:40 | 203.0.113.77 | RT1 | Failure invalid_grant | A retired token from a new address: replay. The family is revoked, RT3 included |
| 09:15:03 | 198.51.100.20 | RT3 | Failure invalid_grant | The app’s current token fails too, so Maria signs in again |
SSOGEN records the third line as token_replay.detected, with the client and the family, never the token. Sender-constraining binds the refresh token to a client key instead, through mTLS or DPoP.
Where to store each token
Keep refresh tokens on a server whenever the architecture allows it.
- Server-rendered web app: server session. Both tokens stay on the server. The browser holds only a session cookie.
- Browser-only app: BFF. A backend for frontend is the confidential client and keeps both tokens server-side (RFC 10017, August 2026, section 6.1). Its section 8.5 notes that localStorage gives no protection from malicious JavaScript in the origin.
- Mobile or desktop app: OS store. Sign in through the system browser, never an embedded web view (RFC 8252). Keep the refresh token in the operating system’s credential store, such as the iOS Keychain.
- Agent or batch job: none. It uses client credentials and asks for a new access token on expiry.
A refresh token taken from any of these outlives the session it came from; the response steps are in session hijacking and token theft.
Refresh tokens in SSOGEN, by caller
The caller type decides whether a refresh token exists.
| Caller | Refresh token | Lifetime |
|---|---|---|
Agent acting on its own |
None: the agent asks again when its access token expires |
A DPoP-bound access token that lasts at most 270 seconds |
Agent acting for a person |
Received after the person approves; rotates on each use. SSOGEN re-checks the person, the delegation and the agent at every refresh |
Lasts for the delegation and lapses after 24 hours idle |
Application signing people in |
Switched on per application, for the authorization code flow |
Idle limit 5 minutes to 24 hours (default 30 minutes); absolute limit 1 hour to 30 days (default 8 hours), never past the person’s sign-in session. Access tokens last 60 seconds |
Service application |
Never: client credentials only |
An access token of 5, 15 (default) or 30 minutes, or 1 hour |
Set these limits per application in the SSOGEN OpenID Connect provider.
Questions people ask
Is refresh token the same as access token?
No. They are separate credentials with different jobs. The access token goes to an API and proves what the client may do there for a few minutes. The refresh token goes only to the authorization server and buys new access tokens. RFC 6749 defines them in sections 1.4 and 1.5, and issuing a refresh token is optional.
How do I get an OAuth 2.0 access token and refresh token?
Exchange an authorization code at the token endpoint. After the person signs in, the client posts the one-use code to /token and receives both tokens in one response, if the server issues refresh tokens. The full exchange is walked through in authorization code flow.
Where should I store access token and refresh token?
On the server, in the session, wherever you can. A browser app should hand both to a backend for frontend and keep only a session cookie. A native app keeps its refresh token in the OS keychain. Avoid localStorage for refresh tokens: any script running in the page’s origin can read it.
Where does the ID token fit?
The ID token is for the client, not for an API. OpenID Connect returns it next to the access token to say who signed in, with the client’s client_id in aud (OpenID Connect Core 1.0, section 2). Never send it to an API as an access token. Only the refresh token renews access.
Sources, all read 2026-11-18: RFC 6749 (sections 1.4, 1.5, 5.1, 5.2, 6, 10.4), RFC 9068 (sections 2.2 and 6), RFC 9700 (section 4.14.2), RFC 7009, RFC 7662, RFC 8252, OpenID Connect Core 1.0 (section 2), RFC 10017 (sections 6.1 and 8.5).
Updated