Skip to main content

Generate a linking token

POST /v2/oauth/token

Generates a linking token from a valid authorization code. The authorization code comes from Instacart and verifies that the customer has granted your site access to their Instacart account. For more information about the authorization code, see How to link an Instacart account.

You can use the generated linking token to link the user account.

Request#

FieldTypeRequiredDescription
client_idstringโœ…The client ID.
client_secretstringโœ…The client secret.
grant_typestringโœ…The grant type.
codestringThe authorization code.
redirect_uristringThe redirect URI when the authorization code was generated.
important

For the linking token, the grant type must be set to authorization_code and the redirect URI must match the one you shared with Instacart.

Request Examples#

curl --request POST \  --url https://connect.instacart.com/v2/oauth/token \  --header 'Accept: application/json' \  --header 'Content-Type: application/json' \  --data '{  "client_id": "string",  "client_secret": "string",  "grant_type": "client_credentials",  "code": "string",  "redirect_uri": "string"}'

Response#

FieldTypeRequiredDescription
access_tokenstringโœ…The token to be used to authenticate requests.
token_typestringโœ…The token type.
expires_innumberโœ…The number of seconds the token will expire in.
created_atnumberโœ…The epoch time of when the token was created.
scopestringThe scope of the token.
note

For linking token, scope will be set to account_linking.

Response Examples#

{  "access_token": "mhtEdMZYPypuW_I0fYken8cAqE7llDaoNefHSeVj9u4",  "token_type": "Bearer",  "expires_in": 86400,  "created_at": 1603897760}