POST /api/v1/auth/refresh • HTTP 200 OK
Refresh Token Rotation API Example — Request & Response Example
Demonstrates secure session renewal without forcing the user to re-enter their username and password.
1. HTTP Client Request (POST)
POST /api/v1/auth/refresh HTTP/1.1
{
"Content-Type": "application/json"
}
{
"refresh_token": "rft_98234871928374"
}
2. Server JSON Response (HTTP 200 OK)
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 900,
"new_refresh_token": "rft_new_0918237461928"
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl -X POST "https://cometflow.space/api/v1/auth/refresh" \
-H "Content-Type: application/json" \
-d '{"refresh_token": "rft_98234871928374"}'
fetch('https://cometflow.space/api/v1/auth/refresh', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ refresh_token: 'rft_98234871928374' })
}).then(res => res.json()).then(console.log);
import requests
res = requests.post("https://cometflow.space/api/v1/auth/refresh", json={"refresh_token": "rft_98234871928374"})
print(res.json())
How This API Call Works Step-by-Step
- 1. Short token expires (e.g. 15 min).
- 2. Client Axios/Fetch interceptor intercepts 401 error.
- 3. Automatically requests /auth/refresh with refresh token.
- 4. Obtains fresh access token and retries original request transparently.
Backend API Functions: The API function rotateRefreshToken() checks token family revocation, issues a newly signed token pair, and invalidates the prior refresh token.
Frequently Asked Questions
What is refresh token rotation?
Every time a refresh token is used, a new one is issued and the old one is invalidated. If a stolen refresh token is used twice, the server detects the breach and revokes all active sessions immediately.