To successfully make API calls, ensure that you include the following headers in your requests:
Authorisation header: this is crucial for authentication. Include the access token obtained during the OAuth flow as a bearer token. The format of the header should be "Bearer + <access_token>".
Accept header: allows you to specify the desired response format from the API. Specify the type of response you expect from the API, such as "application/json" for JSON response. The server will then provide the response in the specified format.
- GET https://public-api.approvalmax.com//ping authorization: Bearer access_token accept: application/json
Make sure to include these headers in your API requests to authenticate and communicate with the API correctly.
Access and refresh tokens
Access tokens have an expiration time of 1 hour. If your application is granted the "offline_access" scope during the initial user authorisation, it can automatically refresh the access token using a refresh token without requiring any user interaction.
To refresh the access token, your application needs to make a POST request to the token endpoint. Here's how you can do it:
- Ensure that you have stored the refresh token securely. It is crucial to protect this sensitive information, such as storing it in the keychain of the operating system, to prevent unauthorised access.
- Make a POST request to the token endpoint using the appropriate parameters.
To refresh the access token, you need to make a POST request to the token endpoint:
When refreshing an access token using a refresh token, the request body must include:
grant_type
=refresh_token. Set this parameter to "refresh_token" to indicate that you are refreshing a token.
refresh_token
=YOURREFRESHTOKEN. Include the stored refresh token in this parameter obtained during the initial authorisation flow.
clientId
: Client app key from your application created in the Developer Portal.
clientSecret
: App secret key from your application created in the Developer Portal.
When refreshing an access token using a refresh token, the response from the token endpoint will include a new access token and refresh token. It is crucial for your application to save both tokens in order to maintain access to the ApprovalMax API.
If your application fails to receive the response or encounters issues while saving the new tokens, you have a grace period of 1 hour. During this grace period, you can retry using your existing refresh token to obtain a new access token. However, after the grace period of 1 hour has elapsed, your previous refresh token will expire. To continue accessing the ApprovalMax API, the user will need to re-authorise your application, which will generate a new refresh token. Handling this scenario is important to ensure uninterrupted access to the API.
You can decode your token
here.