Web DevAuth & SecurityDiagramIntermediate
Refresh Token
KO: 리프레시 토큰 (Refresh Token)·EN: Refresh Token·JA: リフレッシュトークン
A long-lived credential used to mint fresh short-lived access tokens seamlessly without forcing users to log in repeatedly
Table of Contents
Structure Diagram
Short-Lived Access Token & Refresh Token Rotation Cycle
2/42. 401 Token Expired— Client intercepts 401
Client intercepts 401Quick Answer
What is Refresh Token?
A long-lived credential used to mint fresh short-lived access tokens seamlessly without forcing users to log in repeatedly. It is a core concept in Auth & Security within Web Dev.
Core Principles
Stateless JWT Access Tokens are hard to revoke once issued, so security best practice keeps their lifetime very short (5–15 minutes). To avoid logging users out every 15 minutes, servers pair them with a longer-lived Refresh Token (days or weeks) stored in a database or Redis.
Refresh Tokens are sent exclusively to the token-refresh endpoint, enabling seamless session renewal alongside instant server-side revocation.
Practical Takeaways
- Enable Refresh Token Rotation with Reuse Detection: Make each Refresh Token single-use—issue a new pair on every refresh and invalidate the old one. If an already-used token is presented again, treat it as stolen and revoke the entire token family.
- Lock down browser storage: Store Refresh Tokens in
HttpOnly; Securecookies scoped to the refresh path rather thanlocalStorageto protect against XSS. - Deduplicate concurrent refreshes (Single-Flight): When multiple parallel API calls fail with
401at once, coalesce them behind a single in-flight refresh promise so Rotation doesn't falsely flag concurrent retries as token reuse.
Notable Examples
- Auth0, AWS Cognito, and Supabase Auth: Built-in Refresh Token Rotation with automatic reuse detection.
- Mobile & SPA silent authentication: Maintaining multi-week sessions while limiting leaked access token blast radius to minutes.