# auth.md for ByMetz

You are an agent. Most of what you need at ByMetz (https://bymetz.nl) works without any credentials: searching the catalogue, reading products and prices, building a cart and starting a checkout. Only features of a signed-in customer account need OAuth, and that runs through Shopify, the platform ByMetz uses. ByMetz does not issue API keys or OAuth clients itself.

## Step 1: Discover

- Protected resource metadata (RFC 9728): `GET https://bymetz.nl/.well-known/oauth-protected-resource`. It names the resource `https://bymetz.nl` and two authorization servers: `https://account.bymetz.nl` and `https://shopify.com/authentication/94209376520`.
- Authorization server metadata (RFC 8414): `GET https://bymetz.nl/.well-known/oauth-authorization-server`, also at `/.well-known/openid-configuration`. It lists the endpoints, PKCE with S256 and the scopes `openid`, `email`, `customer-account-api:full`, `customer-account-mcp-api:full`, `dev.ucp.shopping.checkout:manage` and `dev.ucp.shopping.catalog.search:read`.
- The full API description is https://bymetz.nl/openapi.json; the human-readable version is https://bymetz.nl/pages/developers.

## Step 2: Pick a method

- `anonymous`: the default. No registration, no token. Use it for the read-only JSON endpoints (`/products.json`, `/products/{handle}.js`, `/collections/{handle}/products.json`, `/search/suggest.json`), for Storefront GraphQL at `POST https://bymetz.nl/api/2026-10/graphql.json` and for the Universal Commerce Protocol over MCP at `POST https://bymetz.nl/api/ucp/mcp`.
- OAuth 2.0 authorization code with PKCE: only to act inside a customer's own account (orders, addresses) with the customer's consent.

## Step 3: Register

- `anonymous`: nothing to register.
- OAuth: the client is registered with Shopify, for example as a Shopify app with Customer Account API access. There is no self-service registration endpoint at ByMetz.

## Step 4: Claim

There is no separate claim ceremony. For OAuth, send the customer to the `authorization_endpoint` (`https://account.bymetz.nl/authentication/oauth/authorize`); the customer signs in on Shopify's own page and approves the requested scopes there. Never ask the customer for a password yourself.

## Step 5: Exchange

Exchange the authorization code at the `token_endpoint` (`https://account.bymetz.nl/authentication/oauth/token`) with the PKCE `code_verifier`. Refresh tokens use the `refresh_token` grant. The metadata also lists `urn:ietf:params:oauth:grant-type:jwt-bearer`; ByMetz has not tested that grant.

## Step 6: Use the access_token

Send it as `Authorization: Bearer <access_token>` (`bearer_methods_supported: ["header"]`) to the Shopify customer account APIs. The anonymous endpoints above ignore it.

## Errors

- Storefront GraphQL answers in JSON: an `errors` array for invalid queries, typed `userErrors` for invalid mutation input, 404 with code `NOT_FOUND` for an unknown API version.
- HTTP 429 means Shopify's rate limit for bots: wait, retry with exponential backoff and cache what you read.
- A checkout always needs the buyer's explicit approval and payment; an agent can never complete a payment on its own.

## Revocation

End the customer's session at the `end_session_endpoint` (`https://account.bymetz.nl/authentication/logout`) when the task is done. Access tokens expire; get a new one with the refresh token, or start again at Step 4. Questions: info@bymetz.nl (e-mail only).
