Refresh Token & Access Token
When working with the Reward API and Reward Links API platform, access tokens are short-lived while refresh tokens are used to generate new access tokens without re-authentication.
How It Works
- Access tokens expire after 30 days.
- Refresh tokens can be used to generate new access tokens programmatically.
- When a new access token is generated using a refresh token, you will also receive a new refresh token. The old refresh token becomes invalid and must be replaced in your system.
Why It Matters
If your access token expires, your API calls will fail. Automating the refresh process ensures uninterrupted API connectivity without manual intervention.
Steps to Generate a New Access Token
- Use a previously obtained refresh token (from the initial OAuth setup).
- Call the Refresh Token API to get:
- A new access token
- A new refresh token
- Expiry details for the access token in EPOCH format
Replace the old refresh token in your system with the new one returned in the response.
Token Invalidation Instances | Error Code |
---|---|
Super Admin resets their account's password | { "success": 0, "error_message_id": "auth.token_error" } |
Super Admin adds another Super Admin and the new Super Admin generates a new token | { "error": "invalid_token", "error_description": "invalid/expired token" } |
Unusual number of requests on Refresh Token API | { "message": "auth.request_limit_exceeded" } |
Important Notes
- Every time you use the refresh token, you will receive a new refresh token — always replace the old one.
- If a 4xx error occurs, generate new tokens using the Refresh Token API.
- Access tokens can be regenerated programmatically, but refresh tokens cannot — once expired, a new refresh token must be generated from the dashboard.
- Xoxoday may invalidate your token for security reasons, such as:
- Super Admin password reset
- Addition of another Super Admin generating a new token
- Unusual number of refresh requests
Best Practices
- Refresh tokens every 15 days or before your access token expires.
- Use a CRON job or scheduler to automatically refresh and store tokens.
- Monitor expires_in in the response to know token lifetime in seconds.
Updated 2 days ago