Implement refresh token rotation with reuse detection

domain: identity-general · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Issue a new refresh token every time a refresh token is used (rotation); immediately invalidate the previously used refresh token upon issuing the replacement.
  2. Group related refresh tokens into a token family by storing a shared family_id alongside each token record in your database.
  3. On each refresh request, look up the presented refresh token; if found and valid, issue a new token, invalidate the old one, and return the new access and refresh tokens.
  4. If the presented refresh token is not found (already rotated or deleted), check whether it belongs to a known family; if it does, this signals a reuse attack — immediately invalidate all tokens in that family and require the user to re-authenticate.
  5. Return an appropriate error (e.g., invalid_grant) to the client when reuse is detected; do not silently ignore the event.
  6. Log reuse detection events with client IP, user id, and token family id for security monitoring and incident response.

Known gotchas

Related routes

Implement Tesla Fleet API refresh token handling correctly, including single-use rotation and the short grace window for token persistence failures
developer.tesla.com · 5 steps · unrated
Implement OIDC session management with refresh token rotation and silent renew in a single-page application
openid.net · 6 steps · unrated
Handle OAuth token refresh races in long-running integrations
oauth-general · 4 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans