Skip to main content

Get an access token

Learn how to authenticate and get an access token in a development environment.

  1. Before you begin
  2. Generate a token

Before you begin

For this tutorial, you need the following items:

  • Your client ID and secret
  • The base URL of your assigned Instacart development server

Generate a token

To make requests to the API, you need a bearer token with the client_credentials grant type. To generate the token, use the authentication endpoint, specify your client ID and secret in the body, and set the scope to connect:ian. If you omit the scope, the access token is valid for all scopes.

curl --request POST \
--url https://<instacart_dev_domain>/v2/oauth/token \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "<your_client_id>",
"client_secret": "<your_client_secret>",
"grant_type": "client_credentials"
"scope": "connect:ian"
}'

The response contains the generated token. The token is valid for 24 hours, after which you need to generate a new token.

{
"access_token": "<your_access_token>",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "connect:ian",
"created_at": 1603897760
}

Use the token in the Authorization header of all requests to the API.