Generate Access Token
This API allows you to exchange an auth code for the access token of a user.
USE CASE
Get a user's access_token from your backend as soon as the redirect returns an auth_code. Keep the app_secret on your server.
Details
- POST the auth_code and appIdHash (SHA-256 of api_id + app_secret) to the Validate Authcode API endpoint to obtain the access_token.
- Send a POST request with a JSON body containing
grant_type(authorization_code),appIdHashandcode, theauth_codefrom the redirect. appIdHashis the SHA-256 hash ofapp_id:app_secret; keep theapp_secreton your server and never share it.- Send
app_id:access_tokenin the HTTPAuthorizationheader on every later request made for this user. - If a token is expired or invalid, API calls return error code -8, -15, -16 or -17. See API Error Codes.
Request Attributes
| Attribute | Data Type | Description |
|---|---|---|
grant_type | string | This value must always be “authorization_code” |
appIdHash | string |
|
code | string | This is the auth_code which is received from the first step |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
s | string | ok / error |
code | int | This is the code to identify specific responses |
message | string | This is the message to identify the specific error responses |
access_token | string | This value will be used for all the subsequent requests. |
Note: FYERS API access tokens expire daily at 6:30 AM. Generate a new token after 6:30 AM for it to remain valid throughout the day.
Last updated on