Documentation
GitHub

Token Refresh Flow Visualization

Control Panel

expired-access-token
0
IDLE
REQUESTING
TOKEN EXPIRED
REFRESHING
SUCCESS

Request Flow

Click "Call Protected API" to start the demo

Current Configuration

registerAxiosTokenRefresh(api, {
  refreshRequest: async () => {
    // Call refresh endpoint with refresh token
    const res = await axios.get("/api/mockApi?type=refresh", {
      headers: { Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJyZWZyZXNoLXRva2VuIiwidHlwZSI6InJlZnJlc2giLCJpYXQiOjE3MjY2NjU2MDB9.refresh_token_signature_here_xyz123" }
    });
    return { accessToken: res.data.accessToken };
  },
  statusCodes: [401], // Trigger refresh on 401
  onRetry: (config) => {
    // Update authorization header for retry
    config.headers["Authorization"] = "Bearer " + newAccessToken;
    return config;
  }
});