OAuth 2.1
Snappy Agents is both the authorization server and the only resource server. Tokens are opaque, stored hashed, and revocable.
The flow end to end
Discovery, dynamic registration, PKCE authorization with hosted sign-in and consent, token exchange, refresh rotation and revocation. All of it is in the Workflows index as well.
sequenceDiagram
autonumber
participant A as Agent platform
participant S as agents.snappy.com
participant U as Shopper browser
A->>S: GET /mcp or /v1/* without a token
S-->>A: 401 with WWW-Authenticate Bearer resource_metadata=/.well-known/oauth-protected-resource
A->>S: GET /.well-known/oauth-protected-resource, then /.well-known/oauth-authorization-server
S-->>A: issuer, endpoints, PKCE S256 only, scopes, registration_endpoint
A->>S: POST /oauth/register (client_name, redirect_uris, auth method none by default)
S-->>A: 201 client_id (client_secret only for confidential clients)
A->>U: open /oauth/authorize with response_type=code, scope, state, code_challenge
U->>S: GET /oauth/authorize
S-->>U: sign-in page, flow kept in a signed cookie session for 30 min
alt Email code
U->>S: POST /oauth/authorize/otp (email)
S-->>U: code page, 6-digit code sent by email (shown inline outside prod)
U->>S: POST /oauth/authorize/verify (code)
else Google
U->>S: POST /oauth/authorize/google (Google ID token)
end
S-->>U: consent page listing scopes, with a Limit to read-only switch
U->>S: POST /oauth/authorize/consent (allow, read_only drops orders:write)
S-->>U: 302 to redirect_uri with code, state and iss (code valid 5 min, single use)
U->>A: callback with code
A->>S: POST /oauth/token grant_type=authorization_code, code, code_verifier
S-->>A: access_token 60 min, refresh_token 30 days when offline_access was granted
A->>S: Bearer calls to /v1/* or /mcp
A->>S: POST /oauth/token grant_type=refresh_token
S-->>A: new access and refresh token, old refresh token revoked (same family)
Note over A,S: Replaying a code or reusing a rotated refresh token revokes every token of that family
A->>S: POST /oauth/revoke (token)
S-->>A: 200, the token and its family are revoked
| Endpoint | Purpose |
|---|---|
GET /.well-known/oauth-authorization-server |
Metadata (RFC 8414). Also served at /.well-known/openid-configuration for clients that look there. |
GET /.well-known/oauth-protected-resource |
Resource metadata (RFC 9728); referenced from WWW-Authenticate on 401. |
POST /oauth/register |
Dynamic client registration (RFC 7591). |
GET /oauth/authorize |
Browser flow: sign-in (email code or Google) → consent (with read-only switch) → redirect with code. |
POST /oauth/token |
authorization_code (PKCE S256 required) and refresh_token (rotating; reuse revokes the family). |
POST /oauth/revoke |
Revoke a token and its family (RFC 7009). |
POST /oauth/introspect |
Introspection for confidential clients (RFC 7662). |
GET /.well-known/jwks.json |
The business signing keys (jwks_uri in the metadata): used by UCP platforms to verify Snappy's HTTP Message Signatures and AP2 merchant authorizations, not for user tokens. |
Scopes
| Scope | Grants | Class |
|---|---|---|
profile |
Email, name, saved addresses | read / write (profile edits) |
catalog:read |
Search, products, availability, collections, address tools | read |
orders:read |
Quotes, checkouts, orders, timelines, SSE | read |
orders:write |
Create quotes and checkouts, cancel, send receipts | write / sensitive-write |
offline_access |
Refresh token | — |
Read-only grants. On the consent screen the user can tick Limit to read-only; orders:write is dropped from the grant. Write endpoints then return 403 with code insufficient_scope and missingScopes, which the agent should turn into "you connected Snappy as read-only; reconnect to buy".
Token lifetimes
| Token | TTL | Notes |
|---|---|---|
| Authorization code | 5 min | Single use; replay revokes every token issued from that grant |
| Access token | 60 min | Bearer header only |
| Refresh token | 30 days | Rotated on each refresh; reuse of an old one revokes the whole family |
Redirect URIs
https only, except http://localhost / 127.0.0.1 for development and custom app schemes. No fragments. Exact match at authorize time.
Client authentication
Public clients use token_endpoint_auth_method: none and PKCE. Confidential clients get a client_secret once at registration and may send it as client_secret_post or HTTP Basic.
Platform clients (client_credentials)
An agent platform registered for ACP or UCP can authenticate as itself instead of carrying an API key. Register a confidential client with grant_types: ["client_credentials"] and the platform scopes, link its client_id to the platform in admin → Protocols (OAuth client), then exchange at POST /oauth/token with grant_type=client_credentials and the client secret (client_secret_post or HTTP Basic). The token has no user behind it (its subject is the platform), lives 60 minutes, comes without a refresh token, and is accepted on the endpoints of the platform's protocol (/acp or /ucp/v1) and the protocol tools on /mcp only; the user endpoints answer 403 platform_token. Conversely a user token is refused on the protocol endpoints.
| Scope | Meaning |
|---|---|
acp:checkout |
Platform access to /acp |
ucp:checkout, dev.ucp.shopping.checkout:manage |
Platform access to /ucp/v1 |
dev.ucp.shopping.order:read |
Alias of orders:read on a shopper's token: reads that shopper's own orders on GET /ucp/v1/orders/:id |
dev.ucp.shopping.order:manage, dev.ucp.shopping.checkout:manage |
Aliases of orders:write when a shopper, not a platform, asks for them in the authorization-code flow |
The UCP spellings are accepted as aliases of Snappy's own scopes, so a UCP platform can ask for either; the platform scopes themselves are kept verbatim on the platform's client.
Identity linking. UCP's dev.ucp.common.identity_linking capability points at this authorization server. A platform that wants to show a shopper their own Snappy orders runs the ordinary authorization-code flow for that shopper (above) with the aliases, and the resulting user token may read the orders it placed through GET /ucp/v1/orders/:id.
Errors
The token endpoint answers RFC 6749 bodies: { "error": "invalid_grant", "error_description": "…" }. The authorize endpoint redirects errors to the registered redirect_uri only after it has been validated; otherwise it renders an HTML error.