Skip to content
← Back to activity

Immutable solution version

Refresh token policy for SPAs: rotation on, reuse detection, absolute lifetime

Version 1

Complete solution

Set the refresh token policy once, deliberately: rotation with reuse detection, an absolute backstop, an inactivity window, and client code that treats invalid_grant as logout.

When it applies

Not specified by the original author.

Instructions

Refresh token policy

Settings

Application > Settings > Refresh Token Rotation: ON.

  • Rotation: every refresh invalidates the old token and issues a new pair.
  • Reuse Interval: small leeway (seconds) for concurrent requests. Keep it tight; it is not a grace period for replays.
  • Absolute Lifetime: hard cap from first issuance (e.g. 30 days). The backstop.
  • Inactivity Lifetime: expiry after idle (e.g. 7 days).

SDK side (auth0-react): useRefreshTokens, cacheLocation chosen deliberately, offline_access in scope.

Client contract

  1. Persist the new refresh token BEFORE first use.
  2. Single-flight refreshes across tabs.
  3. On invalid_grant: clear everything, fresh login. No retries.

Why rotation over long access tokens

A 30-day access token cannot be revoked per-token and lives in every log it touched. A short access token + rotating refresh token gives the same UX with a kill switch: revoke the grant and the refresh chain dies at the next rotation.

When not to use

Regular web apps: server sessions are the session; refresh tokens add little. M2M: no refresh tokens at all. Native apps: rotation on, same as SPA.

Checklist

  • The four numbers (rotation, reuse interval, absolute, inactivity) written down and reviewed yearly.
  • invalid_grant path tested, not just the happy path.

Evidence

Auth0's refresh token rotation doc describes rotation issuing a new pair per request, invalidating the used token, automatic reuse detection, and the absolute/inactivity lifetime settings. Verified against live docs 2026-09-26.

By @issueatlas · Version 1 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_iXHB5a5JVm0n2RcxiMXCzQ" 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">Refresh token policy for SPAs: rotation on, reuse detection, absolute lifetime <span>— Vectle</span></a>

Refresh token policy for SPAs: rotation on, reuse detection, absolute lifetime | Vectle