Creating a Shopify OAuth 2.0 app (authorization code grant)
This guide is part of the Publicus connection catalog. Once you have the credentials, connect the service and Publicus stores them for you.
Distilled from Shopify’s own documentation: Implement authorization code grant manually, Offline access tokens, Online access tokens, Create apps using the Dev Dashboard, and About client credentials. Retrieved 2026-07-03.
Use this flow for apps that authorize against stores you do not own (merchant installs). Every store is addressed by its permanent {shop}.myshopify.com subdomain, which is templated into both OAuth URLs and every API request.
- In the Dev Dashboard, open Apps in the left navigation and select Create app → Start from Dev Dashboard, then name the app.
- Open the app’s Settings to copy its Client ID and Client secret. Keep the secret server-side — it also keys the callback HMAC and is never exposed to a browser.
- Add the callback URL from the connect form to the app’s allowed redirect URLs; Shopify rejects any
redirect_urithat is not registered. - Redirect the merchant to
https://{shop}.myshopify.com/admin/oauth/authorize?client_id=...&scope=...&redirect_uri=...&state=...where:scopeis a comma-separated list of Admin API access scopes (for exampleread_products,write_orders) — Shopify does not use the RFC 6749 space separator;stateis a per-request nonce you store and later verify;- append
grant_options[]=per-userfor an online (per-user) token, or omitgrant_options[]for the default offline token.
- On the callback, verify authenticity before trusting anything: recompute the
hmacparameter as HMAC-SHA256 over the remaining query parameters (drophmac, sort alphabetically) keyed with the client secret, and confirm the returnedstatematches the nonce you issued. Also confirm theshopparameter is a valid*.myshopify.comhostname. - Exchange the
code:POST https://{shop}.myshopify.com/admin/oauth/access_token(Content-Type: application/x-www-form-urlencoded) withclient_id,client_secret, andcodein the body. To request an expiring offline token instead of the default non-expiring one, also sendexpiring=1. - Read the token response:
- Offline, non-expiring (default):
access_token+scope, no expiry — revocable only by uninstalling the app or revoking the secret. - Online (per-user):
access_token,scope,expires_in,associated_user_scope, andassociated_user; the token dies when the user logs out or after 24 hours and cannot be refreshed — re-authorize. - Expiring offline (
expiring=1):access_token,scope,expires_in(3600),refresh_token, andrefresh_token_expires_in(7776000 = 90 days).
- Offline, non-expiring (default):
- Refresh (expiring offline tokens only):
POST https://{shop}.myshopify.com/admin/oauth/access_tokenwithclient_id,client_secret,grant_type=refresh_token, andrefresh_token. Each refresh returns a new access token and a new refresh token and invalidates the previous refresh token — persist the newest. A refresh interrupted by a transient outage can be safely retried within 1 hour of the original attempt. When the 90-day refresh token expires, re-run the authorization flow. - Call the API:
POST https://{shop}.myshopify.com/admin/api/{version}/graphql.jsonwith the headerX-Shopify-Access-Token: <access_token>(the bare token, notAuthorization: Bearer).{version}is a date-based value such as2026-07; a new version ships each quarter and each is supported at least 12 months.
Connect it to Publicus
Section titled “Connect it to Publicus”Open Connections under Credentials, choose Shopify, and pick Shopify OAuth 2.0 (authorization code grant). Publicus asks for exactly the fields listed above and keeps them in your workspace’s secret storage.
See also: Shopify in the catalog.
This guide is maintained by Publicus and published under CC BY 4.0.