A refresh token lets a client get a new short-lived access token without asking the user to sign in again. The access token does the daily work and expires fast. The refresh token stays in safe storage and is used only at the authorization server. Most of the risk sits in the refresh token, so most of your design effort should too. To inspect what your access tokens actually contain while you build this, our JWT Decoder shows the header and claims instantly, with no account needed.
TL;DR
- An access token opens APIs and should be short-lived. A refresh token only buys new access tokens and is sent only to the authorization server.
- Rotate refresh tokens: every refresh returns a new one and invalidates the old one, so a replay becomes detectable.
- Plan revocation up front. Stateless JWTs cannot be recalled, so keep access tokens short and track refresh tokens on the server.
- There is no universal refresh token lifetime. Set it by risk, session length and how fast you must be able to cut access.
- Validate the
audclaim in every API so a token minted for one service cannot be used at another.
Table of Contents
- Access token vs. refresh token
- How the refresh flow works
- Refresh token rotation and reuse detection
- Storing refresh tokens
- Revoking tokens
- How long should a refresh token last?
- The audience claim and key rotation
- A short implementation checklist
- Check your auth endpoints with Pingfloat
- Our perspective
- FAQ
- Sources
Access token vs. refresh token
The OAuth 2.0 standard, RFC 6749, defines an access token as the credential used to reach protected resources. A refresh token is a credential used only with authorization servers to obtain access tokens, and it is usually opaque to the client, meaning the client never reads its contents.
The Microsoft identity platform documentation describes the same split: access tokens carry information about the user and the intended resource and are presented to APIs. Because their validity is short, refresh tokens are exchanged for new ones.
| Access token | Refresh token | |
|---|---|---|
| Purpose | Call protected APIs | Obtain new access tokens |
| Sent to | Resource server (your API) | Authorization server only |
| Lifetime | Short (minutes) | Longer (hours to weeks, by policy) |
| Format | Often a JWT, readable by the API | Often opaque, may also be a JWT |
| If stolen | Usable until it expires | Can keep minting access tokens |
The reason for the split is blast radius. An access token travels with every request, so it is exposed often. Keeping it short limits what a leak is worth. The refresh token travels rarely and to one place, so it can live longer. For default lifetimes and verification basics, see our guide JWT Explained for Developers.
How the refresh flow works
Per RFC 6749, the client authenticates to the authorization server and presents the refresh token. If it is valid, the server issues a new access token and may issue a new refresh token. Issuing refresh tokens is optional on the server's side.
In practice:
- The client calls an API with its access token.
- The API rejects it as expired (HTTP 401).
- The client sends
grant_type=refresh_tokenand the refresh token to the token endpoint, as Okta's guide describes. - The server validates the token, returns new tokens, and, if rotation is on, invalidates the one you submitted.
- The client retries the original request.
Step 2 is where many apps break. If five parallel requests all fail at once, five refresh calls fire, and with rotation the later ones present an already-used token. Queue the refresh so one call runs and the other requests wait for its result. Our write-up on JWT expiration handling and rotation covers this pattern in more detail.
Should a refresh token be a JWT?
It can be, but the standard expects them to be opaque to the client, and only the authorization server needs to understand them. An opaque random string stored server-side is simple to revoke and leaks no claims. A JWT refresh token is self-contained, which makes revocation harder, so if you use one, still keep a server-side record.
Refresh token rotation and reuse detection
Rotation means the server issues a replacement refresh token on every use and immediately invalidates the presented one, while remembering which tokens belong together so reuse can be detected. Amazon Cognito's documentation notes that without rotation the original token stays valid.
Why it matters: if a thief copies a refresh token and uses it, the legitimate client's next refresh fails, or the reverse. Either way, a token that was already consumed shows up twice. RFC 9700, the OAuth 2.0 security best current practice published in January 2025, says the server should then revoke the active token in that family and require a new authorization grant. The server cannot tell whether the attacker or the real client sent the reused token, so it ends both.

Handling retries
Networks drop responses. A client that never received its new token will retry with the old one and look like an attacker. Amazon Cognito documents a configurable grace period of up to 60 seconds for this case. If your provider has no such setting, make the client persist the new token before it discards the old one.
Rotation is not the only defense
OWASP's OAuth2 Cheat Sheet lists sender-constraining (DPoP or mutual TLS) and rotation as the two ways to protect refresh tokens, and treats them as complementary. Sender constraint binds use of the token to a key held by the client, so a copied token is useless without that key. Rotation catches reuse of a token that has already been spent. For the transport side of key binding, read our explainer on certificate pinning and mTLS.
Storing refresh tokens
RFC 9700 calls refresh tokens attractive targets because they represent the client's granted scope and can be replayed to mint access tokens. It recommends confidentiality in transit and at rest, client binding, and client authentication where possible.
What that looks like by platform:
- Server-side web apps: keep the refresh token on the server, tied to the session, and never send it to the browser.
- Single-page apps: avoid long-term storage in places any script can read. A common approach is to let a backend hold the token and give the browser a session cookie.
- Mobile and desktop: Google's guidance points to platform secure storage such as Android Keystore, Apple Keychain Services or Windows Credential Locker, and says tokens should never be sent in plaintext.
Google also notes that refresh tokens should be kept in long-term secure storage and reused while valid, and that provider limits can invalidate older tokens when too many are issued. Do not request a new grant every time the app starts.
Revoking tokens
A signed JWT is valid until it expires, because the API checks the signature and not a database. That is the core limit of stateless tokens, and it shapes the whole design.
Your options:
- Short access tokens. The OWASP JWT Cheat Sheet says short expiration limits reuse of a stolen token.
- Revoke the refresh token. This stops new access tokens at the next refresh. The delay equals the access token's remaining life.
- Denylist. OWASP describes a denylist keyed by the
jti(token ID) andiss(issuer) claims, or Token Status Lists that aggregate status in compressed form. - Revoke on events. RFC 9700 recommends automatic refresh token revocation after security events such as a password change or logout at the authorization server.
- Delete what you no longer need. Google advises revoking tokens when they are no longer needed and deleting them from your systems.
Sender-constrained tokens, such as those bound with DPoP or mutual TLS, make a stolen token far harder to use without its private key. OWASP is clear that this does not prevent the disclosure itself, so pair it with short lifetimes. If you are weighing whether you need JWTs for a given system at all, our comparison sessions for monoliths, JWTs for short-lived APIs helps.
How long should a refresh token last?
No standard gives one number. RFC 9700 leaves expiration to the authorization server, which may use a global value or derive it from client policy, grant sensitivity or inactivity. Treat it as a risk decision:
- Keep access tokens short, on the order of minutes.
- Set the refresh lifetime to how long a user should stay signed in without friction.
- Add an inactivity timeout, so an unused token dies sooner than an active session.
- Use shorter lifetimes where you cannot revoke quickly or where the data is sensitive.
Write down the numbers you choose and the reason. Someone will ask during an incident.
The audience claim and key rotation
The aud claim names the intended recipient of a JWT. RFC 8725, the JWT best current practices document from February 2020, says that when one issuer serves multiple applications, the recipient must validate aud and reject the token if it is absent or not associated with that recipient. Without this, a token issued for your billing API could be replayed at your admin API. OWASP also recommends restricting bearer access tokens to a single resource server where possible, to limit damage from leakage.
A quick check: paste a token into the decoder and confirm aud, iss and exp look right before you trust your validation code.

For signing key rotation, publish public keys with a key ID (kid) in the token header so verifiers can pick the right key, and keep the old public key available until every token it signed has expired. Rotating the signing key is separate from rotating refresh tokens: one protects token authenticity, the other protects token reuse.
A short implementation checklist
- Issue access tokens with
exp,iss,audand ajti. - Return refresh tokens only over TLS, stored hashed on the server where you control it.
- Rotate on every use and keep a token family ID.
- On reuse, revoke the family and force a new sign-in.
- Revoke on password change and logout.
- Validate
audandissin every API. - Log refresh failures so reuse alerts reach someone.
The longer version is in our JWT best practices checklist, and the web security checklist covers the surrounding hardening.
Check your auth endpoints with Pingfloat
Token endpoints are single points of failure: if refresh breaks, every session ends. Pingfloat's Website Uptime Monitor checks site availability, and the SSL Checker verifies the certificate protecting token traffic. Both are free, and the JWT Decoder, JSON Formatter, Base64 tool and timestamp converter on pingfloat.com help when you debug claims and expiry times.

Our perspective
Most refresh token incidents we hear about in developer discussions come from the boring parts: a certificate that lapsed, an endpoint that was down, a timestamp read in the wrong timezone.
That is why we built Pingfloat as a set of free tools you can open without installing anything. Decode the token, convert the
expvalue, format the JSON payload, check the certificate and watch the endpoint, all in one place.Design the token model carefully, then keep an eye on the things around it.
Andreas
FAQ
Should the refresh token be refreshed?
Yes, that is what rotation does. Each successful refresh returns a new refresh token and invalidates the old one. This lets the server detect reuse and revoke the whole token family, as RFC 9700 recommends.
How long does an OAuth refresh token last?
There is no fixed duration in the standards. The authorization server decides, based on client policy, grant sensitivity and inactivity. Choose a lifetime that matches how long a session should persist and how quickly you can revoke it.
Is JWT obsolete?
No. JWTs remain widely used as access tokens for APIs, and current guidance from RFC 8725 and OWASP covers how to use them safely. The practices that matter are short lifetimes, audience validation and a revocation plan.
Can I revoke a JWT access token?
Not directly, since APIs verify the signature rather than check a database. You can keep lifetimes short, revoke the refresh token, or maintain a denylist keyed by jti and iss, as OWASP describes.
Sources
- RFC 6749: The OAuth 2.0 Authorization Framework
- Tokens and claims overview, Microsoft identity platform
- Refresh access tokens and rotate refresh tokens, Okta
- RFC 9700: Best Current Practice for OAuth 2.0 Security
- Refresh tokens, Amazon Cognito
- OAuth2 Cheat Sheet, OWASP
- JSON Web Token Cheat Sheet, OWASP
- Best Practices, Google Authorization Resources
- RFC 8725: JSON Web Token Best Current Practices
