Set up shopper authentication for Adobe Commerce Optimizer

Shopper authentication lets AI agents call your custom tools on behalf of a signed-in shopper. On Adobe Commerce Optimizer, the shopper signs in on your own OAuth 2.0 authorization server:

  • Adobe never sees the shopper’s password.
  • Adobe obtains, encrypts, stores, and refreshes the shopper’s tokens. Agents never receive shopper tokens. They only receive a sign-in link.
  • Your custom tool receives the shopper’s access token in the X-Tool-Authorization header and validates it like any other request to your APIs.

This page is for merchants. Agent builders follow Set up an AI agent for shopper authentication.

Components components

Component
Owned by
Role
Shopper MCP Server
Adobe
The /mcp endpoint that agents call. Authenticates agents, calls your custom tools, and asks the MCP Auth Server for shopper tokens.
MCP Registry
Adobe
Stores your OAuth 2.0 server and client registration, your custom tools runtime, and agent registrations. You call its GraphQL API.
MCP Auth Server
Adobe
Runs the OAuth 2.0 authorization code flow with PKCE against your authorization server, stores, encrypts, and refreshes shopper tokens, and notifies agents.
Your OAuth 2.0 authorization server
Merchant
Signs the shopper in and issues tokens to the MCP Auth Server.
Your redirect page (redirect_uri)
Merchant
Receives the authorization code and state after sign-in, forwards them to the MCP Auth Server, and tells the shopper the result.
AI agent
Agent builder
Calls Shopper MCP Server, sends the shopper to sign in, receives the notification, and retries.

How it works how-it-works

  1. The agent calls one of your custom tools on /mcp with its agent credentials and the shopper’s session ID (X-Session-Id).
  2. Shopper MCP Server calls your custom tools runtime. The call carries no shopper token, so your runtime answers HTTP 401.
  3. Shopper MCP Server asks the MCP Auth Server for a token for this tenant, agent, and session. None exists yet, so the tool returns auth_required with a sign-in link (authorizationUrl).
  4. The agent shows the link to the shopper, who signs in and consents on your authorization server.
  5. Your authorization server redirects the shopper to your redirect_uri. Your backend forwards the query string, unchanged, to the MCP Auth Server callback.
  6. The MCP Auth Server exchanges the code at your token endpoint, stores the tokens, and notifies the agent’s webhook (AUTHORIZED).
  7. The agent retries the same tool call with the same X-Session-Id. Shopper MCP Server calls your runtime again with X-Tool-Authorization: Bearer <shopper-access-token>. Your runtime validates the token and returns the result.

Later calls with the same session ID reuse the token. When your server issues refresh tokens, the MCP Auth Server refreshes the access token automatically, so the shopper does not have to sign in again.

NOTE
Shopper tokens are bound to one tenant, one agent, and one shopper session.

Before you begin before-you-begin

  • Your Adobe Commerce Optimizer instance is onboarded to Shopper MCP Server. See Early access.
  • You have an OAuth 2.0 authorization server for your shoppers that supports the authorization code grant with PKCE (S256) and confidential clients (HTTP Basic client authentication).
  • You have a public HTTPS website where you can host the redirect page.
  • You have your custom tools runtime deployed. See Create a custom tools server.
  • You have the OAuth Server-to-Server credentials that Adobe provides to get an IMS service token. You send this token to the MCP Registry and to the MCP Auth Server callback.

Required information required-information

Information
Description
Example
Tenant ID
The instance ID of your Adobe Commerce Optimizer instance, which agents send in X-Environment-Id. Use the same value in every registration.
89136eae-ac79-40d7-984c-39baa7dd4e9f
View ID
Your Adobe Commerce Optimizer view identifier (X-View-Id).
<your-view-id>
Storefront URL
Public HTTPS URL of the storefront (websiteUrl).
https://www.example.com
Authorization endpoint
HTTPS URL where shoppers sign in.
https://login.example.com/oauth2/authorize
Token endpoint
HTTPS URL that issues tokens, reachable from the internet.
https://login.example.com/oauth2/token
Client ID and client secret
A confidential client that you create on your authorization server for Shopper MCP Server.
smcp-client
Redirect URI
The page on your site that receives the shopper after sign-in. See Step 6.
https://www.example.com/oauth/smcp-callback
Scopes (optional)
OAuth 2.0 scopes that your custom tools need.
openid orders:read
Runtime URL
The MCP endpoint of your custom tools runtime on Adobe I/O Runtime. See Step 2.
https://<namespace>.adobeioruntime.net/api/v1/web/<package>/<action>
IMS service credentials
OAuth Server-to-Server credentials to call the MCP Registry and the MCP Auth Server callback.
Provided by Adobe

Endpoints by environment endpoints

Service
Production
Sandbox
Shopper MCP Server (agents)
https://commerce-storefront.adobe.io/mcp
https://commerce-storefront-sandbox.adobe.io/mcp
MCP Registry GraphQL API
EU: https://eu1.api.commerce.adobe.com/mcp-registry/api/graphql
NA: https://na1.api.commerce.adobe.com/mcp-registry/api/graphql
https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql
MCP Auth Server callback
https://commerce-merchandising-mcp-auth-server.adobe.io/oauth2/callback
https://commerce-merchandising-mcp-auth-server-sandbox.adobe.io/oauth2/callback
TIP
Start in the sandbox environment. Registrations are per environment. Repeat them in production when you are ready to go live.

Step 1: Get an IMS service token ims-token

Request a token with the OAuth Server-to-Server credentials that Adobe provides in the Adobe Developer Console:

curl -X POST 'https://ims-na1.adobelogin.com/ims/token/v3' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'client_id=<your-client-id>' \
  --data-urlencode 'client_secret=<your-client-secret>' \
  --data-urlencode 'scope=<your-adobe-scopes>'

Send every MCP Registry request as a GraphQL POST to the registry of your environment, with the token in the Authorization: Bearer header. To check your access, run:

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{"query": "query { getOAuth2ServerTenant(tenantId: \"<tenant-id>\") { tenantId } }"}'

The response returns null until you register your authorization server in Step 3. Pass secrets as GraphQL variables rather than inline.

Step 2: Register your custom tools custom-tools

Only custom tools can ask for shopper sign-in on Adobe Commerce Optimizer. Register the MCP endpoint of your custom tools runtime first:

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{
    "query": "mutation($input: CustomToolsInput!) { onboardCustomTools(input: $input) { success error } }",
    "variables": {
      "input": {
        "tenantId": "<tenant-id>",
        "runtimeUrl": "https://<namespace>.adobeioruntime.net/api/v1/web/<package>/<action>",
        "createdBy": "<your-name>"
      }
    }
  }'

The registry uses the exact URL that you supply and does not append /mcp. After you deploy tool changes, call refreshCustomTools(tenantId: "<tenant-id>").

Step 3: Prepare your OAuth 2.0 authorization server prepare-server

Create a confidential client for Shopper MCP Server on your authorization server, and check these requirements:

Requirement
Details
Authorization endpoint
Absolute https:// URL that supports response_type=code with PKCE S256. It must not already contain any parameter that the MCP Auth Server adds (response_type, client_id, redirect_uri, state, code_challenge, code_challenge_method, scope), and must not contain a fragment (#).
Redirect URI
Your redirect page (Step 6), exactly as you register it in Step 5.
Token endpoint
Absolute https:// URL on a public host. Hosts that resolve to private, loopback, link-local, or other reserved addresses are refused. Accepts HTTP Basic client authentication (client_secret_basic) with a form body for grant_type=authorization_code (with code, redirect_uri, and code_verifier) and grant_type=refresh_token. Answers within 5 seconds.
Token response
Contains a non-empty access_token and token_type Bearer. expires_in must be longer than 5 minutes, because tokens are refreshed 5 minutes before they expire. Without expires_in, 30 minutes is assumed. refresh_token is optional but recommended: without it, the shopper signs in again when the access token expires. scope is optional and, when present, must be a space-separated string. Granted scopes are read from it, or else from the scope claim of the access token (JWT). If your server grants fewer scopes than requested, sign-in still succeeds with the granted scopes only.
Scopes (optional)
Publish authorization server metadata (RFC 8414) at https://<storefront-host>/.well-known/oauth-authorization-server with scopes_supported. The registry reads it when you register scopes (Step 5). If your authorization server runs on a different domain than the storefront, route /.well-known/oauth-authorization-server from your storefront CDN to your authorization server.

Step 4: Register your OAuth 2.0 authorization server register-server

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{
    "query": "mutation($input: OAuth2ServerTenantInput!) { registerOAuth2ServerTenant(input: $input) { tenantId authorizationEndpoint tokenEndpoint createdAt lastModifiedAt } }",
    "variables": {
      "input": {
        "tenantId": "<tenant-id>",
        "authorizationEndpoint": "https://login.example.com/oauth2/authorize",
        "tokenEndpoint": "https://login.example.com/oauth2/token",
        "type": "ACO",
        "storefronts": [
          {
            "viewId": "<view-id>",
            "locale": "en_US",
            "websiteUrl": "https://www.example.com",
            "privacyPolicyUrl": "https://www.example.com/privacy",
            "termsOfServiceUrl": "https://www.example.com/terms"
          }
        ]
      }
    }
  }'
Field
Required
Notes
tenantId
Yes
Your tenant ID (X-Environment-Id).
authorizationEndpoint
Yes
Absolute https:// URL. See Step 3.
tokenEndpoint
Yes
Absolute https:// URL on a public host. See Step 3.
type
With storefronts
ACO
storefronts
If you use scopes
One entry per Adobe Commerce Optimizer view. Each entry needs viewId. All URLs are absolute https:// URLs. The first storefront with a websiteUrl is used to read your scopes metadata.
customerAccountType
No
GLOBAL or WEBSITE: how customer accounts are shared.
CAUTION
Registering again for the same tenant replaces every field except createdAt. Fields that you leave out are cleared, so always send the complete registration.

Step 5: Register your OAuth 2.0 client register-client

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{
    "query": "mutation($input: OAuth2ClientTenantInput!) { registerOAuth2ClientTenant(input: $input) { tenantId redirectUri clientId scopes secretRotatedAt previousSecretExpiresAt createdAt lastModifiedAt } }",
    "variables": {
      "input": {
        "tenantId": "<tenant-id>",
        "redirectUri": "<redirect-uri>",
        "clientId": "<client-id>",
        "clientSecret": "<client-secret>"
      }
    }
  }'
  • redirectUri is your redirect page (Step 6), not an Adobe URL. It must match the redirect URI configured for the client on your authorization server.
  • The client secret is encrypted before it is stored, and is never returned or logged.
  • scopes is optional. Each scope is 1-256 printable ASCII characters, except space, ", and \. You can register at most 50 distinct scopes. Duplicates are removed, and scopes are case-sensitive. Register the server first (Step 4) with a storefront websiteUrl: every scope must be listed in scopes_supported of https://<websiteUrl-host>/.well-known/oauth-authorization-server, which is read with a 5-second timeout and without following redirects.
  • Scopes are fixed per client ID. To change them, create a new client on your authorization server and register its client ID and secret.

Registry errors registry-errors

Code
Meaning
What to do
BAD_REQUEST
A field is missing or not valid, for example not an https URL, an invalid scope, or an unsupported scope. The message names the field, never the secret.
Fix the field and send the request again. Nothing was stored.
INTERNAL_ERROR
Secret encryption is temporarily unavailable, try again later, or another server error.
Retry later. It is safe to retry.

Step 6: Host your redirect page redirect-page

After sign-in, your authorization server redirects the shopper’s browser to your redirect_uri with code and state, or with error and state. On your server, the page must:

  1. Forward the query string unchanged to the MCP Auth Server callback, GET https://<mcp-auth-server-host>/oauth2/callback?<original-query-string>, with Authorization: Bearer <ims-service-token>.
  2. Redirect the browser (302) to a result page whose URL has no code or state, and show a message based on the result. See Messages for the shopper. If the shopper refreshes the result page, the callback is not sent again.

Example redirect handler (Node.js and Express):

// Your redirect_uri, for example https://www.example.com/oauth/smcp-callback
app.get("/oauth/smcp-callback", async (req, res) => {
  const queryStart = req.originalUrl.indexOf("?");
  const query = queryStart >= 0 ? req.originalUrl.slice(queryStart) : "";
  const response = await fetch(`https://<mcp-auth-server-host>/oauth2/callback${query}`, {
    headers: { Authorization: `Bearer ${await getImsServiceToken()}` },
  });
  const result = await response.json();
  const outcome =
    result.status === "AUTHORIZED" ? "signed-in"
    : result.status === "DENIED" ? "declined"
    : result.error === "invalid_state" ? "expired"
    : "failed";
  // The result page URL carries no code or state, so a refresh does not repeat the callback.
  res.redirect(302, `/oauth/smcp-result?outcome=${outcome}`);
});

Callback responses callback-responses

Situation
HTTP
Response
What it means
Signed in
200
{"status":"AUTHORIZED"}
Tokens are stored and the agent is notified.
The shopper or your authorization server denied the request
200
{"status":"DENIED","error":"access_denied"} (example)
Nothing is stored and the agent is notified. error is the OAuth 2.0 error code that your server returned. It is omitted when the code is not a standard OAuth 2.0 error.
Your server grants fewer scopes than requested
200
{"status":"AUTHORIZED"}
Tokens are stored with the granted scopes only and the agent is notified. Your custom tool handles calls that need a missing scope (Step 7). Check the scopes that your server grants to this client.
Missing, repeated, or extra code or error
400
invalid_request
Forward the original query string unchanged.
Unknown, expired, or used state
400
invalid_state
Sign-in links are valid for 10 minutes and can be used once. Start a new sign-in.
Your token endpoint rejected the code
400
invalid_grant
Start a new sign-in.
Client misconfigured
502
server_error
Fix your registration or your authorization server, then start a new sign-in. See Troubleshooting.
Dependency unavailable
503
temporarily_unavailable
Start a new sign-in. If the retry returns invalid_state, the attempt was already used.

Error responses (4xx and 5xx) are JSON, {"error": "<code>", "error_description": "..."}. The table shows the error code.

Messages for the shopper shopper-messages

Show the shopper a message for every result:

Result
Callback response
Suggested message
Signed in
"status": "AUTHORIZED"
You are signed in. You can go back to the conversation.
Declined
"status": "DENIED"
Access was declined. You can try again from the conversation.
Link expired or already used
"error": "invalid_state"
This link has expired or was already used. Request a new one from the conversation.
Any other error or no response
Any other error, or a timeout
We could not complete the sign-in. Try again from the conversation.

Step 7: Make your custom tools ask for shopper sign-in custom-tool-responses

Answer each request from Shopper MCP Server as follows:

Request
Respond with
initialize, tools/list
A normal response. Never answer 401 here for a missing shopper: a 401 on initialize means that the service credentials of Shopper MCP Server were rejected.
tools/call for a tool that needs a shopper, without X-Tool-Authorization or with a token that is not valid or has expired
HTTP status 401. Shopper MCP Server then starts the shopper sign-in.
tools/call with X-Tool-Authorization: Bearer <shopper-access-token>
Validate the token against your authorization server (signature or introspection, expiry, audience, and scopes), identify the shopper from it, and return the result.
tools/call with a valid token that lacks a scope the tool needs
A normal tool result that explains the missing permission. Do not answer 401, because signing in again grants the same scopes.
tools/call for a tool that does not need a shopper
A normal result.
IMPORTANT
Identify the shopper only from the validated token, never from tool arguments. If your runtime still answers 401 on the retry with a token, the agent receives auth_unavailable, not a new sign-in link.

Step 8: Verify the setup verify

  1. Query your server registration and check the endpoints and storefronts:

    code language-bash
    curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer <ims-service-token>' \
      -d '{
        "query": "query($tenantId: String!) { getOAuth2ServerTenant(tenantId: $tenantId) { tenantId authorizationEndpoint tokenEndpoint type storefronts { viewId websiteUrl } } }",
        "variables": { "tenantId": "<tenant-id>" }
      }'
    
  2. If you use scopes, check that https://<storefront-host>/.well-known/oauth-authorization-server lists them.

  3. With the agent builder, run the end-to-end test in the sandbox:

    1. Call a custom tool that needs a shopper, with a new X-Session-Id. Expect auth_required.
    2. Open authorizationUrl in a browser and sign in with a test shopper.
    3. Confirm that your redirect page shows the success message and that the callback returned AUTHORIZED.
    4. Confirm that the agent’s webhook receives {"status": "AUTHORIZED"} with the same state.
    5. Retry the tool call with the same X-Session-Id. Expect the shopper’s data.
    6. Call the tool again later with the same X-Session-Id. No new sign-in is needed.

    Your runtime receives X-Tool-Authorization only on the retry, and the agent never sees a shopper token.

Maintain your registration maintain

Task
How
Rotate the client secret (recommended once a year)
1. Add a new secret to the client on your authorization server, and keep the old one.
2. Call rotateOAuth2ClientSecret, as shown after this table. The previous secret is still used as a fallback for 7 days.
3. Remove the old secret from your authorization server within those 7 days.
Change scopes
Create a new client on your authorization server, and register its client ID and secret (Step 5). Tokens issued to the old client keep working until they expire.
Update endpoints or storefronts
Register again with the complete input (Step 4).
Remove shopper authentication
Call the delete mutations, as shown after this table.

Rotate the client secret:

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{
    "query": "mutation($secret: String!) { rotateOAuth2ClientSecret(input: { tenantId: \"<tenant-id>\", clientSecret: $secret }) { tenantId clientId secretRotatedAt previousSecretExpiresAt } }",
    "variables": { "secret": "<new-client-secret>" }
  }'

Remove shopper authentication and the custom tools registration:

curl -X POST 'https://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ims-service-token>' \
  -d '{"query": "mutation { deleteOAuth2ClientTenant(tenantId: \"<tenant-id>\") deleteOAuth2ServerTenant(tenantId: \"<tenant-id>\") deleteCustomTools(tenantId: \"<tenant-id>\") { success error } }"}'

Limits and timeouts limits

Item
Value
Sign-in link (state)
Valid for 10 minutes. Can be used once.
Access token refresh
5 minutes before expiry. 30 minutes is assumed without expires_in.
Refresh token retention
365 days after it was last stored.
Token endpoint
5 seconds per request. Must be on a public host.
Client secret after rotation
The previous secret is kept as a fallback for 7 days.
Scopes
At most 50 distinct scopes, each 1-256 characters.
Custom tools discovery
15 seconds, 4 MB per response, 8 MB in total, and 1000 tools.

Troubleshooting troubleshooting

Problem
Solution
Registering scopes fails with BAD_REQUEST.
Register the server first, with a storefront that has a websiteUrl. https://<websiteUrl-host>/.well-known/oauth-authorization-server must answer within 5 seconds, without redirects, and list every scope in scopes_supported. Registering the same client ID with different scopes is rejected. Use a new client.
The callback returns 502 server_error.
The client registration or the authorization server is misconfigured. Check that the client ID and secret match your authorization server, and that the token endpoint is public and answers with access_token, token_type Bearer, and an expires_in longer than 5 minutes.
The agent gets auth_unavailable instead of a sign-in link.
Check that both the authorization server (Step 4) and the client (Step 5) are registered for this tenant, and that the authorization endpoint has no fragment (#) and does not already contain OAuth 2.0 parameters such as client_id or scope. Also check that your runtime accepts the shopper token on the retry.
The callback returns invalid_state.
The link expired (10 minutes), was already used, or the request was forwarded twice. Let the agent call the tool again to get a new link.

FAQ faq

Do agents ever see the shopper’s password or tokens?

No. The shopper signs in on your authorization server. Adobe stores the tokens encrypted and sends them only to your custom tools.

Which tools ask for shopper sign-in?

Only custom tools that answer HTTP 401 on tools/call. See Step 7.

Do I need refresh tokens?

No, but without them the shopper signs in again each time the access token expires.

Can my token endpoint be on a private network?

No. It must resolve to public addresses only, use https://, and be reachable from the internet.

Next step next-step

Share your tenant ID, view ID, and the Shopper MCP Server endpoint with the agent builders, who follow Set up an AI agent for shopper authentication.

recommendation-more-help
commerce-help-shopper-mcp