A step-by-step guide to obtaining an access token from Shopify using OAuth 2.0.
- A Shopify store
- A Shopify Partner account (for app development)
- Access to webhook.site or similar webhook testing service
- Go to dev.shopify.com/dashboard/
- Create a new app
- Navigate to Admin API section
- Choose your permissions carefully (select only what you need)
- Note the scopes you've selected
- Open webhook.site
- Copy the webhook URL provided (keep it handy)
- In your app settings, add this URL to the Redirect URLs section
- Click Release and name the version (e.g., "version1")
- Click on the version you just created
- Verify you can see:
- The scopes you set
- The redirect URL you configured
- Go to App Settings
- Copy your Client ID and Client Secret (keep these secure)
Replace the placeholders in the URL below:
STORE- Your Shopify store name (without .myshopify.com)SCOPE- Your selected scopes (comma-separated, URL-encoded)REDIRECT_URI- Your webhook.site URL (URL-encoded)CLIENT_ID- Your app's Client ID
https://STORE.myshopify.com/admin/oauth/authorize?client_id=CLIENT_ID&scope=SCOPE&redirect_uri=REDIRECT_URI
- Open the authorization URL in a new browser tab
- Install the app on your Shopify store
- After installation, you'll be redirected to webhook.site
- On webhook.site, you'll see the authorization code in the query parameters
- Copy the
codeparameter value
Use the following curl command (replace STORE, CLIENT_ID, SECRET, and CODE):
curl -X POST https://STORE.myshopify.com/admin/oauth/access_token \
-d "client_id=CLIENT_ID" \
-d "client_secret=SECRET" \
-d "code=CODE"The response will contain your access_token.
Test the access token with a GraphQL query:
curl -X POST \
https://STORE.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: YOUR_ACCESS_TOKEN' \
-d '{
"query": "query GetProducts { products(first: 10) { nodes { id title } } }"
}'Note: Replace 2024-01 with the API version you're using. Check Shopify's API versioning for the latest stable version.
- Never commit your
client_secretoraccess_tokento version control - Use environment variables to store sensitive credentials
- The access token has the permissions of the scopes you selected - choose them carefully
- Invalid redirect URI: Make sure the redirect URI in your app settings exactly matches the one in your authorization URL
- Invalid code: Authorization codes expire quickly - make sure you use the code immediately after receiving it
- 403 Forbidden: Check that your scopes include the necessary permissions for the API calls you're making