Does a refresh token have to be a JWT?

Dark navy cover card with the title 'Does a refresh token have to be a JWT?' in white and a green accent bar

No, a refresh token does not have to be a JWT. The OAuth 2.0 spec only says a refresh token is a string, usually opaque to the client, and many providers issue a random value that points to a record on the server. Some systems do use a refresh token JWT, but that is a design choice, not a rule.

What the OAuth spec says about refresh token format

The OAuth 2.0 spec defines a refresh token as a string that represents the authorization a user gave your client, and it sets no format. Section 1.5 of RFC 6749 says the string is "usually opaque to the client". It also says refresh tokens are meant only for authorization servers and are never sent to resource servers.

A JWT earns its keep when someone other than the issuer has to check a token without a lookup. Only the server that created a refresh token ever reads it, and that server can look the value up in its own storage.

The JWT best practices document, RFC 8725, does list refresh tokens as one place JWTs show up. It calls the details "deployment-specific", which is standards language for "your call". The JWT profile for OAuth, RFC 9068, covers access tokens only. No standard defines a refresh token JWT format.

Opaque vs JWT refresh tokens: the trade-offs

An opaque refresh token is a random string with no readable content, while a JWT refresh token carries signed claims anyone holding it can read. The table lists the differences that change how you build the token endpoint.

Question Opaque refresh token JWT refresh token
Can the client read it? No, it is a random value Yes, the payload is only Base64url
How does the server check it? Looks it up in storage Checks the signature, then usually storage too
Revocation Delete or flag the stored record Needs a stored record or deny list anyway
Rotation and reuse detection Natural fit, the server tracks each token Same work, plus signing
Size Short Grows with every claim

Look at the "storage too" cell. Revocation, rotation and inactivity limits all need state on the server, and once you keep that state, the signature adds little.

If you are new to the two token roles, the access token vs refresh token guide explains who receives which one.

Why refresh tokens need server-side state

Refresh tokens need a server-side record because the security rules for them assume the server can cancel or replace any single token. Those rules come from three specs.

  • Revocation. RFC 7009 says implementations MUST support revoking refresh tokens. When one is revoked, the server SHOULD also invalidate access tokens from the same grant.
  • Rotation or sender binding. RFC 9700 says refresh tokens for public clients, such as single-page apps and mobile apps, MUST be sender-constrained or rotated.
  • Inactivity expiry. The same document says refresh tokens SHOULD expire when the client has been inactive for some time.

Rotation shows why. The server issues a new refresh token on every refresh and marks the old one as used. If an attacker and the real client both hold a copy, one of them will present the used token, and the server revokes the active one because it now knows something leaked.

A JWT signature cannot tell the server "this token was already used". Only a stored record can.

How to tell which kind of refresh token you have

You can tell a JWT from an opaque token by its shape. A JWT has three parts separated by dots, and the first part usually starts with eyJ, which is Base64url for {". An opaque token is one long run of characters with no dots, or a format the provider does not document.

When I debug a login flow, I check it like this:

  1. Copy the refresh_token value from the token response in your browser's network tab.
  2. Count the dots. Two dots and an eyJ start mean it is probably a JWT.
  3. Paste it into a JWT decoder to see the header and payload.
  4. If it does not decode, it is opaque. Stop there and treat it as a sealed string.

Decoding shows the claims. It does not prove the token is genuine; decoding vs verifying a JWT covers the difference. The OnlineViewer decoder only decodes: it shows the header, payload, signature and the iat/exp times, but it does not check the signature.

Even if your refresh token is a JWT, your client code should never parse it. The provider can change the format, and the spec never promised the client anything readable.

What providers do with refresh tokens

Big identity providers have mostly settled on opaque refresh tokens. As of November 2026, Auth0 issues opaque refresh tokens that clients cannot decode or inspect, with a maximum length of 4096 characters.

PingOne currently lets you pick either format. Beginning March 2, 2027 it will issue only opaque refresh tokens, and apps that are not updated by March 1, 2027 will get an error. PingOne's reason: an opaque token is only a unique string with no signature, so it is more private and faster.

The hidden risk of JWT refresh tokens: token confusion

The less obvious risk of a JWT refresh token is that it can be mistaken for a different kind of JWT. RFC 8725 calls this cross-JWT confusion: a token issued for one purpose gets accepted somewhere else.

Picture a server that signs access tokens and refresh tokens with the same key and similar claims. If your API only checks the signature and exp, a stolen refresh token works as a long-lived access token, and your short access token lifetimes stop meaning anything.

Fix it with explicit typing. RFC 8725 recommends the typ header for new uses of JWTs. RFC 9068 tells resource servers to accept access tokens only when typ is at+jwt and reject everything else. If you do issue JWT refresh tokens, give them their own typ value, and make sure your API rejects it.

When a JWT refresh token makes sense

A JWT refresh token can make sense when the token server itself is spread across services that share a signing key but not a fast database. The signature lets any node check the token's origin and expiry before the lookup.

My take: unless you run that kind of split token server, make the refresh token an opaque random value and store its hash in the database. You need that record for rotation and revocation anyway, and an opaque value leaks nothing if someone pastes it into a decoder. Save JWTs for access tokens, where a stateless check by the API is the whole point.

The cost is a database hit on every refresh. For most apps that happens once every few minutes per user, which is cheap. A very large system will need caching or a dedicated token store to keep that lookup fast.

For where to keep the token in a browser, see localStorage vs cookies for JWTs. The same concerns apply to opaque refresh tokens.

FAQ

Can I decode my refresh token?

Only if your server issued it as a JWT. Many providers issue opaque refresh tokens that clients cannot decode or inspect, so a decoder shows nothing useful. Your app should treat the value as a sealed string either way.

Is a JWT refresh token less secure than an opaque one?

Not by itself, but it adds risks. The payload is readable by anyone holding it, and a JWT built for one purpose can be swapped in for another unless you type and check it. You also still need a server-side record to revoke it.

Do I need a database for refresh tokens?

In practice, yes. Revocation, rotation and reuse detection all need the server to remember which refresh tokens are still valid, so even a signed JWT refresh token ends up backed by stored state.

Should the refresh token have the same format as the access token?

No. The two tokens go to different places. The access token goes to the API, while the refresh token only goes to the authorization server, so each can use whatever format suits its receiver.

Sources