API Authentication
Overview
This article provides information on the authentication process for API calls.
Each API request made to Fynapse has to be authenticated. Fynapse uses OAuth2 Client Credentials authorization.
The Client Credentials Flow authorization occurs when an application exchanges its application credentials, such as client ID and client secret, for an access token from Fynapse.
How to Generate Client ID and Client Secret Parameters?
- Go to API Credentials in the Developers section of the menu.
- Click Create API credentials, choose who owns the credentials, and confirm with Create.
- In the Save your secret dialog, copy the Client ID and Client Secret, then click Done. Make sure to store the Client Secret securely, as you will not be able to see it again.
The diagram below shows the process of authenticating client credentials using a token:
Requesting Access Token
The access token can be obtained by sending a request to:
https://<instance-url>/auth/token
providing the client id and secret as parameters.
Example request and response below:
Refreshing the Access Token
The token response includes a refresh_token alongside the access_token. When the access token expires, use the refresh token to obtain a new one instead of starting a new session. Send the request to the same POST /auth/token endpoint with the refresh_token grant type:
The client ID and client secret are required for this call, in addition to the refresh token.
The diagram below shows the token refresh process:
The response has the same structure as the initial token response and includes a new refresh token. Two fields define how long the tokens remain valid:
expires_in- the number of seconds until the access token expiresrefresh_expires_in- the number of seconds until the refresh token expires
Always store and use the refresh token from the most recent response. Once the refresh token itself expires, request a new access token using the client_credentials grant type.
Session Timeout
By default, the access token expires 5 minutes (300 seconds) after it is issued, and the refresh token expires after 30 minutes (1800 seconds). Each successful refresh returns a new refresh token, which keeps the session alive. The exact values for your environment are returned in the expires_in and refresh_expires_in fields of the token response.