Prepare a headless storefront sign-in page
If your storefront is not built on Commerce Storefront powered by Edge Delivery Services, implement this contract on your sign-in and create-account pages. The pages complete the OAuth 2.0 request with the Adobe Commerce GraphQL API.
-
Read the request parameters from the query string of the sign-in page:
table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 5-row-3 6-row-3 7-row-3 Parameter Required Description response_typeYes Must be code.client_idYes ID of the OAuth 2.0 client registered in the Commerce Admin. redirect_uriYes Must exactly match a redirect URI registered for the client. code_challengeYes PKCE code challenge. code_challenge_methodYes Must be S256.scopeNo Space-separated scopes. Without it, the client’s allowed scopes apply. stateNo Returned unchanged to the client. -
Keep the parameters while the shopper signs in or creates an account, for example in
sessionStoragefor the current browser tab. They contain no secret. -
Sign the shopper in as usual, for example with the
generateCustomerTokenmutation. -
Call the
issueOauthAuthorizationCodemutation over HTTPS, with the customer token in theAuthorization: Bearerheader:code language-graphql mutation { issueOauthAuthorizationCode(input: { client_id: "<client_id>" redirect_uri: "<redirect_uri>" scope: "<scope>" state: "<state>" code_challenge: "<code_challenge>" code_challenge_method: "S256" }) { redirect_url } } -
Send the browser to
redirect_url, for example withwindow.location.assign(). The URL carriescode,state, andiss, or an OAuth 2.0errorthat the agent handles. The code can be used once and expires after five minutes.
If the mutation returns a GraphQL error, do not redirect. Show the error to the shopper instead. This happens when the client or the redirect URI is not valid, the request does not use HTTPS, or the token is not a customer token.
To let shoppers see and remove the agents they linked, for example on the account page, use the customerOauthAuthorizations query and the revokeOauthAuthorization(client_id) mutation.
Next step next-step
Return to Set up shopper authentication and activate Shopper MCP.