Test account linking
You can simulate creating an Instacart user and then linking a user account with an Instacart account.
- Call the Authorization endpoint. This call generates the access token.
curl --location --request POST 'https://<instacart_development_domain>/v2/oauth/token' \
--header 'Content-Type: application/json' \
--header 'X-Retailer-Id: the-garden' \
--data-raw '{
"grant_type": "client_credentials",
"client_id": "<client_id>",
"client_secret": "<client_secret>"
}'
The response contains the linking token in the access_token
field.
{
"access_token": "l0ebkrG2JAXEuNI9UBpWXO-yC7asltvuyw4RjELk3Hc",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "connect:fulfillment",
"created_at": 1615821019
}
- Create an Instacart user. This generates the user id.
curl --location --request POST \
--url 'https://<instacart_development_domain>/v2/fulfillment_sandbox/instacart_users' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"email": "kamalsingh1234@gmail.com",
"password": <string>,
"phone": "8005550101",
"express_member": true
}'
The response contains the user id. You use the user id to generate an authorization code.
{
"id": 940626754
}
- Request authorization to link accounts. Use the user id to generate an authorization code.
curl --location --request POST \
--url 'https://<instacart_development_domain>/v2/fulfillment_sandbox/instacart_users/940626754/authorize' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"response_type": "code",
"client_id": "e1c700be60cc57c0154ff5aeb3bb57fd079d01dd159fcd85133a3c7c62446ad4",
"scope": "openid account_linking",
"state": "b1a2c3e4f6",
"redirect_uri": "https://example.org",
"hint": "https://example.org"
}'
The response contains the authorization code.
{
"code": "R5n9Jx1LPgXAwAtzxsepptyHHT9K1Cx4qckfc-qZh6c"
}
- Link the accounts.
curl --location --request POST 'https://<instacart_development_domain>/v2/fulfillment/users/38b15dd0-150d-40cf-9c8a-963b0e6c6b9f/link' \
--header 'Content-Type: application/json' \
--header 'X-Retailer-Id: the-garden' \
--header 'Authorization: Bearer <access_token>' \
--data-raw '{
"linking_token": "l0ebkrG2JAXEuNI9UBpWXO-yC7asltvuyw4RjELk3Hc"
}'
The accounts are now linked.