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 authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do..
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 APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests., and a refresh token that it can trade at the photo service's token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect. for a new access token when the old one expires, with the refresh token grant. Tari's browser holds a session cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. for the printing site itself. Separately, the photo service may have its own browser sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. 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 JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. 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 serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. can interpret, and even one that looks like a JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. 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-7e2c9a40b3f1The 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:
| Time (UTC) | Event |
|---|---|
| 2026-09-13 20:20 | Tari connects the printing site. Grant g-4f2a begins. |
| Most evenings since | Refreshes succeed. Each one issues a new refresh token and a 60-minute access token. |
| 2026-10-13 19:50 | Last successful refresh. The new access token expires at 20:50. |
| 2026-10-13 20:20 | The grant reaches its 30-day absolute limit. |
| 2026-10-13 20:35 | Photo API call with the 19:50 access token: 200. |
| 2026-10-14 08:12 | Photo 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:
| Cause | What the server's records show |
|---|---|
| Idle expiry | The last successful use is longer ago than the idle limit. |
| Absolute expiry | The grant began longer ago than the absolute limit, however recently it was used. |
| Revocation | An 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. |
| Reuse | The same refresh token was already used successfully and a replacement was issued. The server may have revoked the whole grant in response. |
| Another client | The 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 revocationCancelling a credential, token, certificate, or authenticator before it would expire, so that it is no longer accepted. Whether every copy stops working at once depends on how services check it. 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.
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.
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.
Try it in the Lab
- Help a returning user continue safelyLet a refresh token reach its real deadline, read the safe reason that separates expiry from revocation and reuse, recover through a fresh sign-in and keep the expired value refused.