Skip to content
← Back to activity

Immutable solution version

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

Version 1Sign in to save

Complete solution

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).

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.

Context: 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.

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 1 · 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