Capability
Identity Linking
The Identity Linking capability (dev.ucp.common.identity_linking) enables OAuth 2.0-based user authentication and authorization.
Overview
Identity Linking allows platforms and AI agents to act on behalf of users with their explicit consent. Built on OAuth 2.0, it enables personalized experiences like saved addresses, loyalty rewards, and payment methods.
Capability Identifier
dev.ucp.common.identity_linkingOAuth 2.0 Flow
UCP uses the standard OAuth 2.0 Authorization Code flow with PKCE for enhanced security.
1. Authorization Request
GET /oauth/authorize
?client_id=YOUR_CLIENT_ID
&redirect_uri=https://platform.com/callback
&response_type=code
&scope=checkout orders loyalty
&state=random_state_value
&code_challenge=BASE64URL(SHA256(verifier))
&code_challenge_method=S2562. User Authorization
User is redirected to the business's authorization page where they review and approve the requested scopes.
3. Authorization Callback
GET https://platform.com/callback
?code=AUTHORIZATION_CODE
&state=random_state_value4. Token Exchange
POST /oauth/token
Content-Type: application/json
{
"grant_type": "authorization_code",
"code": "AUTHORIZATION_CODE",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"redirect_uri": "https://platform.com/callback",
"code_verifier": "ORIGINAL_VERIFIER"
}Token Response
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "dGhpcyBpcyBhIHJlZnJlc2g...",
"scope": "checkout orders loyalty"
}Available Scopes
checkoutCreate and manage checkout sessionsordersView order history and statusloyaltyAccess loyalty points and rewardsaddressesAccess saved shipping addressespayment_methodsUse saved payment methodsprofileAccess basic user profile informationToken Refresh
POST /oauth/token
Content-Type: application/json
{
"grant_type": "refresh_token",
"refresh_token": "dGhpcyBpcyBhIHJlZnJlc2g...",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}Token Revocation
POST /oauth/revoke
Content-Type: application/json
{
"token": "eyJhbGciOiJSUzI1NiIs...",
"token_type_hint": "access_token",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}Using Access Tokens
Include the access token in the Authorization header for all API requests:
GET /checkout/sessions/sess_abc123
Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
Content-Type: application/jsonSecurity Best Practices
- Always use PKCE - Protects against authorization code interception
- Validate state parameter - Prevents CSRF attacks
- Store tokens securely - Never expose in client-side code
- Request minimal scopes - Only request what you need
- Handle token expiry - Implement refresh token rotation
Error Handling
{
"error": "invalid_grant",
"error_description": "The authorization code has expired"
}Common Error Codes
invalid_request- Malformed request parametersinvalid_client- Client authentication failedinvalid_grant- Authorization code expired or invalidunauthorized_client- Client not authorized for this grant typeinvalid_scope- Requested scope is invalid or unknown
Next Steps
- Learn about Order Capability for tracking purchases
- Explore Buyer Consent Extension for GDPR compliance
- See Platform Integration for implementation examples
U
Ready to Get Started?
Join the waitlist for early access to UCPStore and start building with UCP.
Join Waitlist