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-Authorizationheader 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
/mcp endpoint that agents call. Authenticates agents, calls your custom tools, and asks the MCP Auth Server for shopper tokens.redirect_uri)How it works how-it-works
- The agent calls one of your custom tools on
/mcpwith its agent credentials and the shopper’s session ID (X-Session-Id). - Shopper MCP Server calls your custom tools runtime. The call carries no shopper token, so your runtime answers HTTP
401. - 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_requiredwith a sign-in link (authorizationUrl). - The agent shows the link to the shopper, who signs in and consents on your authorization server.
- Your authorization server redirects the shopper to your
redirect_uri. Your backend forwards the query string, unchanged, to the MCP Auth Server callback. - The MCP Auth Server exchanges the code at your token endpoint, stores the tokens, and notifies the agent’s webhook (
AUTHORIZED). - The agent retries the same tool call with the same
X-Session-Id. Shopper MCP Server calls your runtime again withX-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.
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
X-Environment-Id. Use the same value in every registration.89136eae-ac79-40d7-984c-39baa7dd4e9fX-View-Id).<your-view-id>websiteUrl).https://www.example.comhttps://login.example.com/oauth2/authorizehttps://login.example.com/oauth2/tokensmcp-clienthttps://www.example.com/oauth/smcp-callbackopenid orders:readhttps://<namespace>.adobeioruntime.net/api/v1/web/<package>/<action>Endpoints by environment endpoints
https://commerce-storefront.adobe.io/mcphttps://commerce-storefront-sandbox.adobe.io/mcphttps://eu1.api.commerce.adobe.com/mcp-registry/api/graphqlNA:
https://na1.api.commerce.adobe.com/mcp-registry/api/graphqlhttps://na1-sandbox.api.commerce.adobe.com/mcp-registry/api/graphqlhttps://commerce-merchandising-mcp-auth-server.adobe.io/oauth2/callbackhttps://commerce-merchandising-mcp-auth-server-sandbox.adobe.io/oauth2/callbackStep 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:
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 (#).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.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.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"
}
]
}
}
}'
tenantIdX-Environment-Id).typestorefrontsACOstorefrontsviewId. All URLs are absolute https:// URLs. The first storefront with a websiteUrl is used to read your scopes metadata.customerAccountTypeGLOBAL or WEBSITE: how customer accounts are shared.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>"
}
}
}'
redirectUriis 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.
scopesis 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 storefrontwebsiteUrl: every scope must be listed inscopes_supportedofhttps://<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
BAD_REQUESThttps URL, an invalid scope, or an unsupported scope. The message names the field, never the secret.INTERNAL_ERRORSecret encryption is temporarily unavailable, try again later, or another server error.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:
- Forward the query string unchanged to the MCP Auth Server callback,
GET https://<mcp-auth-server-host>/oauth2/callback?<original-query-string>, withAuthorization: Bearer <ims-service-token>. - Redirect the browser (
302) to a result page whose URL has nocodeorstate, 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
200{"status":"AUTHORIZED"}200{"status":"DENIED","error":"access_denied"} (example)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.200{"status":"AUTHORIZED"}code or error400invalid_request400invalid_state400invalid_grant502server_error503temporarily_unavailableinvalid_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:
"status": "AUTHORIZED""status": "DENIED""error": "invalid_state"Step 7: Make your custom tools ask for shopper sign-in custom-tool-responses
Answer each request from Shopper MCP Server as follows:
initialize, tools/list401 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 expired401. Shopper MCP Server then starts the shopper sign-in.tools/call with X-Tool-Authorization: Bearer <shopper-access-token>tools/call with a valid token that lacks a scope the tool needs401, because signing in again grants the same scopes.tools/call for a tool that does not need a shopper401 on the retry with a token, the agent receives auth_unavailable, not a new sign-in link.Step 8: Verify the setup verify
-
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>" } }' -
If you use scopes, check that
https://<storefront-host>/.well-known/oauth-authorization-serverlists them. -
With the agent builder, run the end-to-end test in the sandbox:
- Call a custom tool that needs a shopper, with a new
X-Session-Id. Expectauth_required. - Open
authorizationUrlin a browser and sign in with a test shopper. - Confirm that your redirect page shows the success message and that the callback returned
AUTHORIZED. - Confirm that the agent’s webhook receives
{"status": "AUTHORIZED"}with the samestate. - Retry the tool call with the same
X-Session-Id. Expect the shopper’s data. - Call the tool again later with the same
X-Session-Id. No new sign-in is needed.
Your runtime receives
X-Tool-Authorizationonly on the retry, and the agent never sees a shopper token. - Call a custom tool that needs a shopper, with a new
Maintain your registration maintain
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.
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
state)expires_in.Troubleshooting troubleshooting
BAD_REQUEST.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.502 server_error.access_token, token_type Bearer, and an expires_in longer than 5 minutes.auth_unavailable instead of a sign-in link.#) 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.invalid_state.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.