Obtain a new access token using a valid refresh token. This endpoint allows you to maintain authenticated sessions without requiring the user to sign in again.
Refresh tokens have a longer lifespan than access tokens (typically 30 days vs 1 hour) and can be used multiple times until they expire.
Token Rotation: Each refresh operation provides both a new access token and a new refresh token. The old refresh token becomes invalid immediately.Expiration: Refresh tokens typically last 30 days from their creation date, regardless of usage frequency.Revocation: Refresh tokens are automatically revoked when a user signs out or changes their password.
Refresh tokens 5-10 minutes before they expire rather than waiting for 401 errors. This provides a better user experience.
Secure Storage
Store refresh tokens securely. In web applications, consider HTTP-only cookies instead of localStorage for production environments.
Error Recovery
Implement graceful fallbacks when token refresh fails. Save user progress and redirect to authentication with context.
Background Refresh
Consider refreshing tokens in background workers or when the application regains focus to maintain continuous authentication.
Never expose refresh tokens in URLs, logs, or client-side code where they could be compromised. Treat them with the same security as passwords.
The new refresh token returned in the response should replace the old one immediately. Attempting to use an old refresh token after a successful refresh will result in an authentication error.