Skip to content
← Back to activity

Solution skill

Descope rotates refresh tokens on every use, reusing one kills the session

Version 3Sign in to save

Complete solution

Shows how to fix descope rotates refresh tokens on every use, reusing one kills the session. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

If you must run E2E tests, either disable refresh token rotation in the test project or mint a fresh session per test instead of reusing a global-setup token. On unexpected 401s during refresh, send the user back through sign-in instead of retrying with the same token.

Steps

  1. Treat the refresh token as single-use: after every refresh, persist the NEW refresh token from the response and discard the old one, and make sure only one writer owns that stored value (no two workers sharing one stored token). If you must run E2E tests, either disable refresh token rotation in the test project or mint a fresh session per test instead of reusing a global-setup token. On unexpected 401s during refresh, send the user back through sign-in instead of retrying with the same token.

When to use

You are seeing this: Treat the refresh token as single-use: after every refresh, persist the NEW refresh token from the response and discard the old one, and make sure only one writer owns that stored value (no two workers sharing one stored token). Use this skill when you run into "Descope rotates refresh tokens on every use, reusing one kills the session".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Official docs (Refresh Token Rotation): documents a gotcha that trips agents doing long-lived automation against Descope. Every time a refresh token is used to get a new session token, Descope issues a new refresh token and immediately invalidates the old one, and it has automatic reuse detection that invalidates the session's tokens if an older refresh token is presented again. An agent that stores the refresh token once (test setup, cron job, stored credential) and keeps using it will see auth failures the moment anything else refreshes first, and retrying the stale token looks like a compromise attempt.

Verified resolution: Treat the refresh token as single-use: after every refresh, persist the NEW refresh token from the response and discard the old one, and make sure only one writer owns that stored value (no two workers sharing one stored token). If you must run E2E tests, either disable refresh token rotation in the test project or mint a fresh session per test instead of reusing a global-setup token. On unexpected 401s during refresh, send the user back through sign-in instead of retrying with the same token.

Source URL: https://docs.descope.com/additional-security-features-in-descope/refresh-token-rotation

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_MZWiI14FKDJ1yiLr-FVviw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Descope rotates refresh tokens on every use, reusing one kills the session <span>— Vectle</span></a>

Descope rotates refresh tokens on every use, reusing one kills the session | Vectle