This guide introduces you to the authentication and authorization methods that you will use to connect to Shopify's APIs.
You can use Shopify CLI to generate a starter app with boilerplate code that handles authentication and authorization. The starter app includes code for an embedded app that follows app best practices:
You should use this starter app unless you need to scaffold an app that is not embedded.
To learn more about the authentication and authorization methods that you can use for Shopify apps, and the libraries that you can use to simplify your implementation, refer to authentication and authorization.
The Storefront API supports both tokenless and token-based access. For token-based access, requests require a valid Shopify access token. The following types of tokens are available:
Public access tokens: Used to make requests from client-side applications, such as a browser or mobile app.
Private access tokens: Used to make requests from a server or other private context.
Apps can have a maximum of 100 active storefront access tokens per shop.
Public access tokens enable your app to make Storefront API requests from public contexts like a browser. With public access, capacity scales with the number of buyers based on customer IP. In most cases, this is the IP of someone browsing your site or using your mobile app. Learn more about Storefront API rate limits.
To use public access, you need to create a public access token for your app by making a request to the GraphQL Admin API's storefrontAccessTokenCreate
mutation. Alternatively, you can create a custom app in the Shopify admin, and retrieve your Storefront API access token and manage access scopes from there.
To query the Storefront API with a public access token, include it as an X-Shopify-Storefront-Access-Token
header on all client-side requests.
Private access tokens let you make authenticated, server-side queries to the Storefront API.
CautionUnlike public access tokens, private access tokens should be treated as secret and not used on the client-side. We recommend only requesting the scopes that your app needs, to reduce the security risk if the token leaks.
To start using private access, you can use the following methods:
Add the Headless channel to your Shopify admin.
Create a delegate access token for your custom app.
Request unauthenticated scopes on an existing access token.
To query the Storefront API with a private access token:
Shopify-Storefront-Private-Token
header with the access token.In some cases, a request to the Storefront API isn't linked to buyer traffic, such as during a static site build, however when making server-side requests to the Storefront API as a result of buyer traffic, be sure to also:
Shopify-Storefront-Buyer-IP
(case-sensitive) header with the IP address of the buyer. This allows Shopify to accurately enforce IP-level bot and platform protection, to help your storefront manage traffic from a single user consuming a high level of capacity, such as a bot.Failure to include the Shopify-Storefront-Buyer-IP
(case-sensitive) header, can result in sub-optimal user experiences, including throttled API requests, limited Bot Protection, and unauthenticated flows at checkout as Shopify will not be able to differentiate requests from different buyers.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4