Skip to content
Docs

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.

  1. In the Dev Dashboard, open Apps in the left navigation and select Create app → Start from Dev Dashboard, then name the app.
  2. 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.
  3. Add the callback URL from the connect form to the app’s allowed redirect URLs; Shopify rejects any redirect_uri that is not registered.
  4. Redirect the merchant to https://{shop}.myshopify.com/admin/oauth/authorize?client_id=...&scope=...&redirect_uri=...&state=... where:
    • scope is a comma-separated list of Admin API access scopes (for example read_products,write_orders) — Shopify does not use the RFC 6749 space separator;
    • state is a per-request nonce you store and later verify;
    • append grant_options[]=per-user for an online (per-user) token, or omit grant_options[] for the default offline token.
  5. On the callback, verify authenticity before trusting anything: recompute the hmac parameter as HMAC-SHA256 over the remaining query parameters (drop hmac, sort alphabetically) keyed with the client secret, and confirm the returned state matches the nonce you issued. Also confirm the shop parameter is a valid *.myshopify.com hostname.
  6. Exchange the code: POST https://{shop}.myshopify.com/admin/oauth/access_token (Content-Type: application/x-www-form-urlencoded) with client_id, client_secret, and code in the body. To request an expiring offline token instead of the default non-expiring one, also send expiring=1.
  7. 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, and associated_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, and refresh_token_expires_in (7776000 = 90 days).
  8. Refresh (expiring offline tokens only): POST https://{shop}.myshopify.com/admin/oauth/access_token with client_id, client_secret, grant_type=refresh_token, and refresh_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.
  9. Call the API: POST https://{shop}.myshopify.com/admin/api/{version}/graphql.json with the header X-Shopify-Access-Token: <access_token> (the bare token, not Authorization: Bearer). {version} is a date-based value such as 2026-07; a new version ships each quarter and each is supported at least 12 months.

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.