Overview
This guide covers common issues you might encounter when implementing OAuth 2.0, along with their solutions and prevention strategies.Quick Debug Tip: Most OAuth issues fall into one of three categories: PKCE validation, state parameter mismatch, or token confusion. Check these first.
Remember: OAuth troubleshooting is about ensuring users can successfully authorize your application to act on their behalf. Technical issues may prevent users from granting or using the permissions they intend to provide.
Common Errors
invalid_request - Missing required parameters
invalid_request - Missing required parameters
Error Response:Causes:
- Missing PKCE parameters (
code_challenge,code_challenge_method) - Missing
response_typeor incorrect value - Missing
stateparameter - Missing
client_idorredirect_uri
- Verify all required parameters are present
- Check parameter names match exactly (case-sensitive)
- Ensure PKCE parameters use correct encoding (base64url)
invalid_grant - Invalid or expired authorization code
invalid_grant - Invalid or expired authorization code
invalid_client - Authentication failed
invalid_client - Authentication failed
Error Response:Causes:
- Incorrect
x-client-keyorx-secret-key - Using sandbox keys in production (or vice versa)
- Keys revoked or expired
- Missing required headers
- Verify both client key and secret key are correct
- Ensure you’re using keys for the correct environment
- Check headers are named exactly:
x-client-keyandx-secret-key - Contact support if keys need to be regenerated
State parameter mismatch
State parameter mismatch
Symptom:
Client-side validation fails when comparing state parameters.Causes:
- State not stored correctly in session
- State modified during OAuth flow
- User restored from different session/device
- CSRF attack attempt
- Store state in secure session storage
- Validate state exactly (case-sensitive)
- Don’t allow state to be modified
- Restart OAuth if state mismatch occurs
redirect_uri mismatch
redirect_uri mismatch
Error Response:Causes:
- Redirect URI not whitelisted in environment config
- URI doesn’t match exactly (protocol, domain, path)
- Trailing slash mismatch
- Query parameters in URI
- Contact admin to whitelist exact redirect URI
- Ensure exact match including protocol (https://)
- Don’t include query parameters in redirect_uri
- Match trailing slashes exactly
Session expired (10 minutes)
Session expired (10 minutes)
Error Response:Causes:
- More than 10 minutes between initiation and authorization
- User took too long on hosted UI
- Network delays or user distraction
- Complete OAuth flow within 10 minutes
- Display countdown timer to users
- Restart flow if session expires
- Don’t pre-initiate OAuth too early
Token confusion - Using wrong token type
Token confusion - Using wrong token type
Symptom:
401 Unauthorized despite having tokens.Causes:
- Using JWT token for API calls (should use access token)
- Using login access token for final API calls
- Mixing up tokens between OAuth steps
- JWT Token: Only in Step 3 request body (API mode)
- Login Access Token: Only in Step 3 Authorization header (API mode)
- Final Access Token: For all subsequent API calls
- Refresh Token: Only for token refresh endpoint
PKCE validation failed
PKCE validation failed
Error Response:Causes:
- code_verifier doesn’t match original code_challenge
- Incorrect SHA256 hashing
- Base64url encoding issues
- Using different verifier than original
- Verify SHA256 hash is correctly computed
- Use base64url encoding (not standard base64)
- Store and retrieve exact same verifier
- Check verifier length (43-128 characters)
OTP required but not provided
OTP required but not provided
Error Response:Causes:
- User has OTP/2FA enabled
- OTP code not included in login request
- Check login response for
requiresOtpfield - Call OTP send endpoint to trigger code delivery
- Prompt user for OTP code
- Retry login with
otpCodeparameter
401 after successful token exchange
401 after successful token exchange
Symptom:
API calls fail with 401 immediately after getting access token.Causes:
- Using wrong access token (e.g., login token instead of final token)
- Token not being sent in Authorization header
- Incorrect Bearer format
- Missing x-client-key header
- Use access_token from token exchange response
- Include in Authorization header as “Bearer ”
- Always include x-client-key header
- Check for extra spaces or formatting issues
Refresh token not working
Refresh token not working
Error Response:Causes:
- Refresh token expired (7 days)
- Using old refresh token (tokens rotate)
- Token was revoked
- Incorrect grant_type parameter
- Check refresh token hasn’t expired
- Always use the newest refresh token (they rotate)
- Clear tokens and re-authenticate if refresh fails
- Ensure grant_type is “refresh_token”
Debugging Strategies
1. Check Request/Response
1
Enable Network Logging
Use browser DevTools or a proxy to inspect requests:
2
Verify Headers
Ensure all required headers are present:
x-client-key: Always requiredx-secret-key: Required for OAuth endpointsAuthorization: Required for authenticated endpointsContent-Type: Required for POST/PUT requests
3
Check Response Codes
Different status codes indicate different issues:
400: Bad request (missing/invalid parameters)401: Authentication failed (invalid token/credentials)403: Forbidden (valid auth, insufficient permissions)498: Invalid client key499: Missing client key
2. Validate PKCE Flow
3. Trace Token Lifecycle
Environment-Specific Issues
Sandbox vs Production
Sandbox Issues
- HTTP allowed in sandbox only
- Different client keys per environment
- Sandbox data doesn’t transfer to production
- Rate limits may differ
Production Issues
- HTTPS strictly required
- Redirect URIs must be whitelisted
- More strict validation
- Lower tolerance for errors
Regional Routing
If using US environment:Prevention Best Practices
1. Implement Comprehensive Error Handling
2. Add Validation Checks
3. Set Up Monitoring
Testing Tools
OAuth Flow Tester
Getting Additional Help
Check API Status
Verify there are no ongoing incidents or maintenance:
- Check status page
- Review error rates in dashboard
- Confirm environment availability
Review Logs
Enable detailed logging to capture:
- Request/response bodies
- Header values (sanitize secrets!)
- Timing information
- Error stack traces
Contact Support
When contacting support, include:
- Error messages and codes
- Request/response examples (sanitized)
- Environment (sandbox/production)
- Approximate timestamp of issues
- Client key (NOT secret key)
Community Resources
Get help from the community:
- Search documentation
- Review example implementations
- Check for similar issues
- Share non-sensitive code samples
Quick Reference
OAuth Error Codes
| Error Code | Meaning | Typical Cause | Solution |
|---|---|---|---|
invalid_request | Missing/invalid params | Incorrect API call | Check all required parameters |
invalid_grant | Code invalid/expired | Used code twice or expired | Restart OAuth flow |
invalid_client | Auth failed | Wrong keys | Verify client credentials |
access_denied | User denied | User clicked deny | Expected behavior, handle gracefully |
unauthorized_client | Client not authorized | OAuth not enabled | Contact administrator |
HTTP Status Codes
| Code | Meaning | Action |
|---|---|---|
400 | Bad Request | Check request parameters |
401 | Unauthorized | Check authentication tokens |
403 | Forbidden | Check permissions/scope |
404 | Not Found | Check endpoint URL |
498 | Invalid Client Key | Verify x-client-key header |
499 | Missing Client Key | Add x-client-key header |
500 | Server Error | Retry or contact support |
