Renew JWT Token
POST/token/renew-token
Generates a new JWT token using an existing and valid token. Typical Flow:
- Client detects that the token will expire soon (less than 1 hour)
- Sends a request with the current token in the Authorization header
- The server validates the current token
- Generates a new token with an extended expiration date (24 more hours)
- Returns the new token to the client
- Client replaces the old token with the new one Usage Examples:
- Extend user session without requiring a new login
- Implement "remember me" by automatically renewing tokens
- SPA application renews token every 23 hours
- System keeps session active during continuous use Renewal Strategies:
- Proactive: Renew 1 hour before expiration
- In Interceptor: Renew automatically on 401 error
- Periodic: Renew every 12 hours if there is activity
- Manual: User clicks "extend session" Security Features:
- Only works with valid, non-expired tokens
- The old token is invalidated after renewal
- New token has the same permissions as the old one
- Renewal is logged for auditing
- Limit of 10 renewals per day per token Important Notes:
- Token must still be valid (not expired)
- User must still be active in the system
- New expiration is 24 hours from the time of renewal
- An already expired token cannot be renewed (use /auth/login)
- Ideal for maintaining long sessions without compromising security
Responses
- 200
- 401
Token successfully renewed
Invalid or expired token