Follow these three steps to authenticate using an Access Key:
Step 1: Create An Access Key
Generate an access key from the Token Management page in Anodot.
Step 2: Exchange the Access Key for a Bearer Token
Use the Access Key to request a bearer token.
POST 'https://{{app-url}}/api/v2/access-token/?responseformat=JSON' \
--header 'Content-Type: application/json' \
--data-raw '{
"refreshToken" : "{{access-key}}"
}
'
"{{bearer-token-string}}"
{
"token" : "{{bearer-token-string}}"
}Step 2 Request Arguments
| Argument | Description |
|---|---|
| refreshToken | Access Key copied from the Token Management in Anodot App |
| responseformat [Optional] | Set to JSON (case sensitive!) to get the response in a json format |
Bearer Token’s Expiration
- The bearer token’s expiration is determined by the User Session Timeout setting, configured under the Authentication tab in the Settings page
Step 3: Use the Bearer Token in API Calls
Include the bearer token in all subsequent API requests by setting the Authorization header: Authorization: Bearer <your_bearer_token>
curl -X GET \
https://{{app-url}}.anodot.com/api/v2/feedbacks \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer {{your_bearer_token}}"
-d '{"startTime" : 1578391000, "endTime": 1578392000}'
Checking token expiration:
- The token consists of three sections separated by dots.
- Extract the second section (the payload) located between the two dots.
- Decode this section from Base64 to obtain a JSON object.
- The decoded object contains an
expfield, which represents the expiration time as a Unix timestamp.- Implement logic in your code to refresh the token before it reaches its expiration time.
