Get an access token

Once you receive the Public_token be sure to exchange it for an Access_token by calling the /connection/public_token/exchange endpoint.

Your front-end code will listen to the event containing the Public_token that is sent from the Link widget. You can then make a call to your backend with this token in order to exchange it for and Access_token, which is the key required for accessing your end-user account data.

Make sure to send this call from your backend to ensure the security of your client ID and secret. You need to include your client_id, Secret and the Public_token associated with this connection in the request for exchanging the public token for an access token. In the end, you will receive the secure Access_token and the connection_id which you can save for all future communications with respect to this connection.

📘

Refer to the Quickstart code sample to see how to securely exchange from your backend a public_token provided by the Link widget for an access_token

Make this call from your backend to exchange a public_token for an access_token

Request

curl -X POST 'https://sandbox.datadeck.co/api/v1/connection/public_token/exchange' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'x-datadeck-client-id: ***Your client id***' \
-H 'x-datadeck-secret: ***Your secret***' \
-d '{"public_token":"public-sandbox-73469138-87fc-4b22-db20-08dc0b1c05bc"}'

Response

{
  "access_token": "access-sandbox-21d7f130-7588-4a31-753c-08dc0b1caad7",
  "connection_id": "191678d2-2805-4505-8b59-08dc0b1c058f"
}

💡

You will need the Access_token to perform all calls to the product endpoints of the Deck API.