Skip to main content
MCP serverOAuth + bearer tokens
MCP server

OAuth + bearer tokens

Connect agents with durable tokens you can scope, rotate, and revoke without touching a personal login.

Bearer auth for MCP — API keys, OAuth 2.1 with PKCE, dynamic client registration, token lifetimes, errors.

MCP authenticates with a bearer token. Either an aly_* API key (long-lived, owner-issued) or an aly_oauth_* OAuth token (consent-issued, refreshable). Both formats are accepted on the same Authorization header.

No session cookies
Forwarding a browser session JWT to the MCP endpoint will be rejected. Agent surfaces require a credential whose lifetime, owner, and scope set are durable and revocable.

Header

http
Authorization: Bearer aly_a8d9c1...e3c7Content-Type: application/json

API key flow

  1. Go to Aly → Settings → API keys.
  2. Click New key, name it, pick scopes.
  3. Copy the key once. It starts with aly_.
  4. Put it in your MCP client config under Authorization: Bearer ....

OAuth 2.1 flow

For multi-tenant integrations where each user installs the integration into their own workspace.

1. Register the OAuth client

Use dynamic client registration, or register a static client in the dashboard. You'll receive a client_id and client_secret.

2. Send the user to consent

http
GET https://aly.store/oauth/authorize  ?response_type=code  &client_id=<id>  &redirect_uri=<uri>  &scope=read:sites read:content read:orders  &state=<random>  &code_challenge=<pkce>  &code_challenge_method=S256

3. Exchange the code

bash
curl -X POST https://aly.store/oauth/token \  -d grant_type=authorization_code \  -d code=<code> \  -d redirect_uri=<uri> \  -d client_id=<id> \  -d client_secret=<secret> \  -d code_verifier=<pkce-verifier>

The response body contains access_token (aly_oauth_*), refresh_token, expires_in, and the granted scope string.

4. Call MCP

Use the access token exactly as you would an API key — Authorization: Bearer aly_oauth_....

Discovery

OAuth 2.1 metadata is published in standard form:

bash
curl https://aly.store/.well-known/oauth-authorization-server

Token lifetime

API keyOAuth access tokenOAuth refresh token
Default lifetimeIndefinite until revoked1 hour30 days, rotating
RevocableYes — dashboardYes — /oauth/revokeYes — /oauth/revoke
RefreshableN/AVia refresh tokenRotated on use

Errors

StatusMeaningAction
401Missing or invalid tokenMint a new key or refresh.
403Token valid, scope insufficientReissue with the needed scope.
429Rate limitHonor Retry-After.
Updated

Was this page helpful?