Skip to main content

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

Error Response:
Causes:
  • Missing PKCE parameters (code_challenge, code_challenge_method)
  • Missing response_type or incorrect value
  • Missing state parameter
  • Missing client_id or redirect_uri
Solutions:
  1. Verify all required parameters are present
  2. Check parameter names match exactly (case-sensitive)
  3. Ensure PKCE parameters use correct encoding (base64url)
Example Fix:
Error Response:
Causes:
  • Authorization code already used (codes are single-use)
  • Code expired (10-minute lifetime)
  • Code_verifier doesn’t match code_challenge
  • Too much time between OAuth steps
Solutions:
  1. Restart OAuth flow from Step 1
  2. Don’t reuse authorization codes
  3. Verify PKCE verifier matches the original challenge
  4. Complete token exchange within 10 minutes
Example Fix:
Error Response:
Causes:
  • Incorrect x-client-key or x-secret-key
  • Using sandbox keys in production (or vice versa)
  • Keys revoked or expired
  • Missing required headers
Solutions:
  1. Verify both client key and secret key are correct
  2. Ensure you’re using keys for the correct environment
  3. Check headers are named exactly: x-client-key and x-secret-key
  4. Contact support if keys need to be regenerated
Example Fix:
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
Solutions:
  1. Store state in secure session storage
  2. Validate state exactly (case-sensitive)
  3. Don’t allow state to be modified
  4. Restart OAuth if state mismatch occurs
Example Fix:
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
Solutions:
  1. Contact admin to whitelist exact redirect URI
  2. Ensure exact match including protocol (https://)
  3. Don’t include query parameters in redirect_uri
  4. Match trailing slashes exactly
Example Fix:
Error Response:
Causes:
  • More than 10 minutes between initiation and authorization
  • User took too long on hosted UI
  • Network delays or user distraction
Solutions:
  1. Complete OAuth flow within 10 minutes
  2. Display countdown timer to users
  3. Restart flow if session expires
  4. Don’t pre-initiate OAuth too early
Example Fix:
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
Solutions:
  1. JWT Token: Only in Step 3 request body (API mode)
  2. Login Access Token: Only in Step 3 Authorization header (API mode)
  3. Final Access Token: For all subsequent API calls
  4. Refresh Token: Only for token refresh endpoint
Example Fix:
Common Mistake: Using the JWT token from Step 1 for API calls. The JWT is ONLY for OAuth flow coordination.
Error Response:
Causes:
  • code_verifier doesn’t match original code_challenge
  • Incorrect SHA256 hashing
  • Base64url encoding issues
  • Using different verifier than original
Solutions:
  1. Verify SHA256 hash is correctly computed
  2. Use base64url encoding (not standard base64)
  3. Store and retrieve exact same verifier
  4. Check verifier length (43-128 characters)
Example Fix:
Error Response:
Causes:
  • User has OTP/2FA enabled
  • OTP code not included in login request
Solutions:
  1. Check login response for requiresOtp field
  2. Call OTP send endpoint to trigger code delivery
  3. Prompt user for OTP code
  4. Retry login with otpCode parameter
Example Fix:
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
Solutions:
  1. Use access_token from token exchange response
  2. Include in Authorization header as “Bearer
  3. Always include x-client-key header
  4. Check for extra spaces or formatting issues
Example Fix:
Error Response:
Causes:
  • Refresh token expired (7 days)
  • Using old refresh token (tokens rotate)
  • Token was revoked
  • Incorrect grant_type parameter
Solutions:
  1. Check refresh token hasn’t expired
  2. Always use the newest refresh token (they rotate)
  3. Clear tokens and re-authenticate if refresh fails
  4. Ensure grant_type is “refresh_token”
Example Fix:

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 required
  • x-secret-key: Required for OAuth endpoints
  • Authorization: Required for authenticated endpoints
  • Content-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 key
  • 499: 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

HTTP Status Codes

Next Steps

OAuth Quick Start

Start implementing OAuth from scratch

Security Best Practices

Review security guidelines

Token Management

Master token lifecycle

API Reference

Detailed endpoint documentation