Error E061301 during Google OAuth token exchange ...
# ask-a-descoper
s
Error E061301 during Google OAuth token exchange Issue Summary: Implementing Google OAuth authentication using Descope Web JS SDK. The OAuth flow initiates successfully and redirects to Google, but fails during the token exchange phase with error code E061301: "Failed to exchange token". Flow Details: 1. ✅ User clicks "Continue with Google" button 2. ✅
sdk.oauth.start('google', redirectUrl)
returns 200 with Google authorization URL 3. ✅ User redirected to Google OAuth consent screen 4. ✅ User authorizes and Google redirects back with authorization code 5. ❌
sdk.oauth.exchange(window.location.href)
returns 401 Unauthorized with error E061301 Configuration: In Descope Console (Authentication Methods → Social Login → Google): - Google OAuth is enabled - Client ID: [redacted].apps.googleusercontent.com` - Client Secret: Verified and matches Google Cloud Console exactly - Redirect URLs configured:
https://[my-domain].com/login
In Google Cloud Console: - Application type: Web application - Authorized redirect URIs:
https://api.descope.com/v1/oauth/callback
- Authorized JavaScript origins:
https://[my-domain].com
- OAuth consent screen: External, scopes include email, profile, openid - Status: Testing (my email added as test user) Error Response:
Copy code
{
  "code": 401,
  "ok": false,
  "error": {
    "errorCode": "E061301",
    "errorDescription": "Failed to exchange token",
    "errorMessage": "Failed exchanging sso token"
  }
}
SDK Implementation:
Copy code
// Start OAuth
const result = await sdk.oauth.start('google', 'https://[my-domain].com/login');
// Redirects successfully

// Exchange (after redirect back)
const exchangeResult = await sdk.oauth.exchange(window.location.href);
// Returns E061301 error
Verified: - ✅ Client ID and Secret are correct and match exactly - ✅ Descope's callback URL (
https://api.descope.com/v1/oauth/callback
) is in Google's authorized redirect URIs - ✅ My app's redirect URL is configured in Descope - ✅ Google+ API is enabled - ✅ Waited several minutes after configuration changes - ✅ OTP authentication (email/SMS) works correctly with the same project Question: What could cause E061301 specifically? Is there additional configuration needed in Descope for Google OAuth, or are there logs I can check to see the actual error from Google's token endpoint? Descope SDK version: @descope/web-js-sdk@latest (from unpkg CDN)
m
can you attach a cf-ray header value from response that failed ?
s
9a6477de4dc64425-BOM
m
it seems you are passing wrong code to exchange OR using that code twice
Copy code
sdk.oauth.exchange(window.location.href);
here , you should provide code you got from
sdk.oauth.start
result , specifically
result.code
s
Hey thanks! That fixed it.