Cobalt API/SDK for Session Token
- Request : In your server side code, make a POST Request to the
/session-token
endpoint or call the .getTokenForLinkedAccount() method of the NodeJS SDK. The request should include thelinked-account_id
of the user for which the Session token is to be generated.
The session token gets expired in 24 hours. Please make sure you generate a new token in every new session or within 24 hours.
- Handle the response: Cobalt will respond with a JSON Object containing the
token
if request was successful. Parse the JSON response body and extract thetoken
.
Response
- Store the Session token: It is critical to store Session tokens securely, as they grant access to sensitive user data. Implement a secure storage solution to store Session tokens and do not log or expose tokens to your frontend application.
-
Handle Errors: If the
/session-token
endpoint returns a 500 error, your server-side code should handle it gracefully. The error is returned due to providing an incorrect linked_account_id while making the request.
Checkpoint + Next Step
After completing this step, you now have the Session Token for your Linked Accounts. But before you make the API Calls, first let’s Display the apps/integrations on Client-side.