Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

A returning user's refresh fails with invalid_grant

A refresh refused with invalid_grant looks the same whether the grant expired, was revoked or was replayed. This lesson follows a customer who is asked to reconnect her photo account, separates those causes with the server's reason and the grant's timeline, and recovers through a fresh authorization.

Tari is asked to sign in again

All names, domains and identifiers in these examples are fictional. A message reaches the printing company's support queue early on a Wednesday: "Last night I was laying out my photo book and everything worked. This morning the app made me sign in to my photo account again. I haven't changed anything. Did someone get into my account?" It comes from Tari, who connected her photo account to the printing site about a month ago and uses it most evenings.

Being asked to sign in again is not an error in itself. It is what an application should do when it can no longer continue on the user's behalf. Tari's real question is whether this was the ordinary end of a connection or a sign of something worse, and the answer decides what you tell her and whether anyone needs to look at her account.

Start by listing what was involved in "the app remembered me". The printing site's backend holds an access token that it presents to the photo API, and a refresh token that it can trade at the photo service's token endpoint for a new access token when the old one expires, with the refresh token grant. Tari's browser holds a session cookie for the printing site itself. Separately, the photo service may have its own browser session for Tari, the one that lets her skip the password when she is already signed in there. Each of those has its own lifetime, and none of them is required to end at the same moment as the others.

Read the refresh failure in its stage

The printing site's trace for Tari's connection shows two failures a few milliseconds apart. First the photo API refused the access token:

GET /albums/4410/pages HTTP/1.1
Host: api.photos.example
Authorization: Bearer <redacted>

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token", error_description="The access token expired"

That one is routine. The invalid_token challenge is the API's way of saying the token itself is no longer good, as Using access tokens described. Access tokens are short-lived on purpose, and the backend responded the way it should, by asking the token endpoint for a replacement:

POST /token HTTP/1.1
Host: auth.photos.example
Authorization: Basic <redacted>
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=<redacted>

HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
X-Request-ID: 0b7d4c1e-93a2-4f6b-8d15-7e2c9a40b3f1

{"error": "invalid_grant", "error_description": "The refresh token is invalid, expired or revoked."}

This is the stage that failed, and it is the one that matters. The access token expiring only meant the backend needed a new one. The refresh being refused meant it could not get one, so the site sent Tari to sign in.

invalid_grant is deliberately broad. RFC 6749, in section 5.2, uses it when the grant or refresh token presented is invalid, expired or revoked, or was issued to another client. A server that rotates refresh tokens, issuing a new one with each refresh as Refresh tokens and rotation described, also answers invalid_grant when it sees a token that has already been used. The status line and JSON body are identical for all of them, and the error_description is free text that many servers keep vague on purpose. Retrying the same request will not change the answer, so a well-behaved client stops and starts a new authorization instead.

Nor does the refresh token itself help. Refresh tokens are often opaque strings that only the authorization server can interpret, and even one that looks like a JWT carries contents meant for that server, not for diagnosis. Do not decode it, paste it into a ticket or send it to anyone. The X-Request-ID is the reference to share.

The server's reason and the chronology

The authorization server knows exactly why it refused the token, because it made the decision. The photo service's audit trail has the record for that request ID:

time        2026-10-14T08:12:04.117Z
operation   oauth.token.refresh
outcome     rejected
reason      refresh_expired
detail      absolute_lifetime_reached
client      printer-web
subject     user-7310 (Tari)
grant       g-4f2a
request_id  0b7d4c1e-93a2-4f6b-8d15-7e2c9a40b3f1

The reason is a strong lead, but check it against the grant's history before you rely on it. Reason names vary between servers, and a timeline is what lets you explain the decision to someone else. Grant g-4f2a is the chain of refresh tokens that began when Tari connected her account. The photo service applies two limits to it, an idle limit of 7 days and an absolute limit of 30 days:

The history of Tari's grant
Time (UTC)Event
2026-09-13 20:20Tari connects the printing site. Grant g-4f2a begins.
Most evenings sinceRefreshes succeed. Each one issues a new refresh token and a 60-minute access token.
2026-10-13 19:50Last successful refresh. The new access token expires at 20:50.
2026-10-13 20:20The grant reaches its 30-day absolute limit.
2026-10-13 20:35Photo API call with the 19:50 access token: 200.
2026-10-14 08:12Photo API call: 401, token expired. Refresh: 400 invalid_grant, reason refresh_expired.

The last use was about twelve hours before the failed refresh, well inside the 7-day idle limit. The grant began almost 30 and a half days earlier, past the absolute limit. The reason and the chronology agree.

Each of the other causes would have left a different trail:

How each cause of invalid_grant shows up on the server
CauseWhat the server's records show
Idle expiryThe last successful use is longer ago than the idle limit.
Absolute expiryThe grant began longer ago than the absolute limit, however recently it was used.
RevocationAn earlier event ended the grant: the user removed the app's access, an administrator disabled the account, or a security policy revoked the user's grants.
ReuseThe same refresh token was already used successfully and a replacement was issued. The server may have revoked the whole grant in response.
Another clientThe token was issued to a different client_id from the one that authenticated, for example when two apps share a token store.

Tari's grant has no revocation event and no earlier use of the refused token, so nothing here points at theft. If you do not run the authorization server yourself, the request ID is what you give the provider's support team so they can read the same record.

Two deadlines, and two tokens

The idle and absolute limits answer different worries. The idle limit ends a grant nobody is using, such as one left on a laptop that was sold or a phone in a drawer. Each successful refresh resets that clock. The absolute limit ends a grant on a fixed date however actively it is used, which caps how long anyone holding the newest refresh token, including someone who copied it, can keep going without the user signing in again. Tari used the app every evening, so the idle limit never came close. The absolute limit was always going to end her grant about a month after she connected. These are the two limits Refresh tokens and rotation introduced.

Look again at 20:35 in the timeline. The grant had already ended, yet the photo API accepted Tari's request. That is expected. The access token issued at 19:50 has its own lifetime, and the refresh grant reaching its deadline does not shorten it. This server does not trim access token lifetimes to fit the grant's deadline, though some servers do. An API that validates the token locally, or asks the authorization server whether the token is still active with token introspection, will keep accepting it until 20:50 unless something actually revokes it. That is why Tari saw nothing wrong last night and was stopped this morning.

Tari's grant ends at 20:20, but the access token it issued keeps its own deadline. Refresh expiry ends continuation, not every credential at the same time.

The reverse also holds. A still-valid access token is not a way back to a refresh token. When the grant ends, the ability to get new tokens ends with it, and the only thing left is whatever access token is still running out its clock.

Recover with a fresh authorization

Once a refresh fails with invalid_grant, the stored refresh token is finished. The printing site should discard it and start a new authorization request, with a new state and a new PKCE verifier, exactly as it did when Tari first connected.

If Tari might still have a session at the photo service, the site can try a silent request first by adding prompt=none, which asks the provider to answer without showing any page, as Prompt and account selection described. If her session is still active and no new consent is needed, a code comes straight back and she never notices. If not, the provider returns an error instead of a sign-in page:

HTTP/1.1 302 Found
Location: https://printer.example/callback?error=login_required&state=<redacted>&iss=https%3A%2F%2Fauth.photos.example

That is what happened for Tari, because her photo service session had also lapsed overnight. On login_required, the site checks state as usual and then repeats the request without prompt=none, so Tari sees the sign-in page. A silent attempt made in a hidden frame often fails in browsers that block cookies in embedded third-party content, as How browser privacy changes affect federation explained, so many applications make it as a short top-level redirect instead.

Tari signs in, the code exchange succeeds, and the photo service starts a new grant with a new refresh token. What the site must not do matters as much. It must not keep retrying the old refresh token, ask Tari for her photo service password so it can sign in on her behalf, or ask anyone to extend the expired grant. A fresh authorization creates new authority. It does not make the old refresh token valid again, and that token should keep returning invalid_grant for good.

The site can make the moment less alarming, too. It can keep Tari's book draft, explain that the photo connection needs renewing about once a month, and return her to the page she was on once she has signed in.

Choose lifetimes for the use

Tari's ticket raises a fair product question: is a monthly sign-in right for a photo book app? There is no universal answer. A shorter absolute limit reduces how long a stolen refresh token stays useful and makes users sign in more often. A longer one is smoother and gives a copied token more time. The idle limit should be longer than the gap people normally leave between uses, or regular customers will be logged out between visits. A nightly sync job that runs with no user present has a different pattern from someone ordering a book twice a year, and is usually better served by its own client and policy than by stretching everyone's lifetimes.

Access token lifetime is a separate choice. It sets how long a token keeps working after its grant ends or is revoked, at least at APIs that do not check revocation on every request.

If the printing company decides 30 days is too short, it changes the policy deliberately. Whether a change applies to existing grants or only to new ones depends on the server, so check before promising customers anything. Either way, a longer policy for future grants is no reason to accept a refresh token after its recorded deadline.

Worked example: the handoff note

Before replying to Tari, the engineer confirms recovery: a refresh with the new grant's refresh token returns 200, and the expired token from g-4f2a still returns invalid_grant. Then they write the note:

Symptom:       Customer asked to reconnect her photo account (2026-10-14 08:12 UTC, production).
               Asked whether her account was compromised.
Failed stage:  Refresh at auth.photos.example: 400 invalid_grant
               (request 0b7d4c1e-93a2-4f6b-8d15-7e2c9a40b3f1).
Cause:         Grant g-4f2a reached its 30-day absolute limit at 2026-10-13 20:20.
               Server reason refresh_expired, detail absolute_lifetime_reached.
               Last use 19:50, inside the 7-day idle limit.
Ruled out:     No revocation event, no earlier use of the refused token, client matches.
               The 20:35 API success used an access token valid until 20:50.
Recovery:      Silent request returned login_required; interactive sign-in created grant g-81c0.
Verification:  g-81c0 refresh: 200. Expired g-4f2a token: still invalid_grant.
Not changed:   Token lifetimes, customer account, customer password.
Follow-up:     Product to review whether a 30-day absolute limit suits the photo book flow.

The reply to Tari can now be specific: nothing suggests anyone else used her account, the connection ends about a month after it is made, and signing in again started a new one.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

Tari's refresh request returns 400 with error invalid_grant. Which evidence tells you whether her refresh token expired, was revoked or was reused? 1 of 3

Choose one answer.

A grant's absolute limit passes at 20:20. A refresh at 19:50 issued a 60-minute access token. At 20:35 the app calls the API with that access token, which nothing has revoked. What should happen? 2 of 3

Choose one answer.

After a refresh fails with invalid_grant, the site sends a new authorization request with prompt=none and gets login_required back. What should it do next? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity