Initiate OAuth Authorization
Authentication
Initiate OAuth Authorization
First step of OAuth 2.0 Authorization Code Flow with PKCE
GET
Initiate OAuth Authorization
Overview
Initiates the OAuth authorization process and returns a hosted UI URL where users authenticate. This is the first step in the OAuth 2.0 Authorization Code Flow with PKCE (Proof Key for Code Exchange). Theredirect_uri provided must be whitelisted in your environment configuration. Authorization sessions expire after 10 minutes, so you must complete the flow before expiration.
When to Use
- Starting an OAuth 2.0 authorization flow for third-party access
- Implementing secure delegated authentication
- Need users to grant permission to your application
PKCE Requirements
PKCE (Proof Key for Code Exchange) is mandatory for security. You must:- Generate
code_verifier: 43-128 random characters from[A-Za-z0-9-._~] - Create
code_challenge:BASE64URL(SHA256(code_verifier)) - Send
code_challengein this request - Store
code_verifiersecurely for use in Step 4 (token exchange)
Flow Types
Hosted UI Flow (Default)
When not usingmode=api, this endpoint redirects to a hosted UI where users authenticate:
- Call this endpoint to get hosted UI URL (302 redirect or JSON with URL)
- Redirect user to hosted UI for authentication
- User authenticates and grants permission automatically in UI
- User is redirected back to your
redirect_uriwith authorization code - Exchange authorization code for tokens via
POST /v1/auth/oauth/token
API Mode Flow
When usingmode=api, you handle authentication in your application:
- Call this endpoint with
mode=apito get JWT token - Authenticate user via
POST /v1/auth/loginto get access token - Call
POST /v1/auth/oauth/authorizewith both tokens to obtain authorization code - Exchange authorization code for tokens via
POST /v1/auth/oauth/token
Request
Query Parameters
Your public API client key (same as x-client-key header)Format: UUIDExample:
100a99cf-f4d3-4fa1-9be9-2e9828b20ebbMust be
code (authorization code flow only)Allowed values: codeYour callback URL where user will be redirected after authorizationMust be whitelisted in environment settingsExample:
https://yourapp.com/callbackCSRF protection token. Client-defined random string returned unchanged in callbackMinimum length: 8 charactersVerify this matches your original value when receiving the callbackExample:
random_csrf_protection_string_12345PKCE code challenge.
BASE64URL(SHA256(code_verifier))Pattern: 43-128 characters from [A-Za-z0-9-._~]Example: M5iYUROLfJajkMMUkn3gpEquAVQpnK4m55NCeK40nlsPKCE challenge method. Must be
S256 (SHA256 hashing)Allowed values: S256Client secret key - only required if secret key is issued for your environmentExample:
100a99cf-f4d3-4fa1-9be9-2e9828b20eaaSet to
us to route requests to the US backend environment (if available for your client)Allowed values: usDefault: international environmentSet to
api to return JSON instead of 302 redirect. Useful for API-only integrationsAllowed values: apiHeaders
Your public API client key
Your secret API key (required only if secret key is issued)
Response
JWT session token (valid for 10 minutes) - only returned when
mode=apiFormat: JWTExample: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...Hosted UI URL where user should authenticateFormat: URIExample:
https://app.example.com/account/login?token=eyJhbGc...Success Responses
- 200 OK (API Mode)
- 302 Found (Default)
Returned when:
mode=api parameter is providedError Responses
400 Bad Request - Invalid Parameters
400 Bad Request - Invalid Parameters
- Missing or invalid PKCE parameters
- Invalid
response_type(must becode) - Missing required parameters (
client_id,redirect_uri,state) - Invalid parameter formats
422 Validation Error
422 Validation Error
redirect_urinot whitelisted in environment configuration- Invalid URL format
- Parameter validation failures
429 Too Many Requests
429 Too Many Requests
498 Invalid Client Key
498 Invalid Client Key
x-client-key header contains an invalid or unknown key.499 Missing Client Key
499 Missing Client Key
x-client-key header is missing.Code Examples
Edge Cases and Important Notes
Session Expiration: Authorization sessions expire after 10 minutes. If your user doesn’t complete authentication within this window, you must restart the flow from Step 1.
PKCE Code Verifier Storage
Thecode_verifier must be stored securely and retrieved during token exchange (Step 4):
- Web apps: Use
sessionStorageor secure session cookies - Mobile apps: Use secure device storage (Keychain on iOS, Keystore on Android)
- Server-side apps: Store in secure session or database with expiration
Multiple Simultaneous Sessions
Each authorization session is independent. You can have multiple concurrent sessions with differentstate values, but each requires its own PKCE pair.
Rate Limiting
The endpoint implements rate limiting to prevent abuse. If you receive a 429 error, implement exponential backoff:Next Steps
After initiating authorization:Step 2: User Authentication
If using API mode, authenticate the user to get an access token
Step 3: Generate Authorization Code
Generate the authorization code using the JWT token
Step 4: Token Exchange
Exchange the authorization code for access and refresh tokens