Implement Shopify Customer Account API OAuth flow in a Hydrogen app to authenticate buyers and access account data

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. Configure the Customer Account API credentials in your Hydrogen app by setting the customer account client ID and redirect URI in the environment variables and passing them to createCustomerAccountClient in the server entry
  2. Implement a login route that calls customerAccount.authorize() to redirect the buyer to the Shopify-hosted login page with the correct OAuth parameters including PKCE code challenge
  3. Create a callback route at the redirect URI that calls customerAccount.authenticate() to exchange the authorization code for tokens; store the resulting access and refresh tokens in the session
  4. Use customerAccount.query() in route loaders to call the Customer Account GraphQL API with the buyer's access token to fetch orders, addresses, or profile data
  5. Implement a logout route that calls customerAccount.logout() to revoke the session and redirect the buyer to the Shopify logout endpoint
  6. Handle token refresh transparently by relying on the Hydrogen customer account client's built-in refresh logic; check whether the session is valid before each protected route load

Known gotchas

Related routes

Initialize the Shopify Storefront API client in Hydrogen with a public access token and query a product by handle including metafields
shopify.dev · 6 steps · unrated
Implement the Shopify Customer Account API OAuth flow in a headless storefront to authenticate buyers without classic customerAccessToken
shopify.dev · 6 steps · unrated
Initialize a Hydrogen storefront with createStorefrontClient and make an authenticated Storefront API request inside a Remix loader
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,800+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans