OAuth2 User-Agent Flow (Gmail API): token exchange always fails with 401 "Invalid Credentials" even though Google returns a valid authorization code

Authentication method: OAuth2 User-Agent Flow, provider: Google (Gmail API)

Setup:

What happens:
I run the app with ?debug_mode=true, trigger a “Signup/login with a social network” workflow action tied to this connection, go through Google’s consent screen, and accept. Google redirects back to /api/1.1/oauth_redirect successfully. I land back in my app, but with:

“API Connector error: the Oauth2 API [Gmail API] is not configured properly - Received error from api. The service Gmail API just returned an error (HTTP 401)… ‘Invalid Credentials’ / ‘authError’ (sometimes ‘missing required authentication credential’, depending on the attempt).”

Clicking “Initialize call” on any Action in this connection fails the same way, in ~250-400ms — too fast to represent a real popup/handshake, suggesting it’s reusing a token that was never actually obtained.

What I’ve ruled out:

  • App ID / App Secret — regenerated the secret in Google Cloud, re-pasted, still fails
  • Header Key — manually retyped "Authorization: Bearer " with trailing space
  • Scope — confirmed complete, not truncated
  • Popup blocking — no blocked-popup icon in the address bar
  • Browser/editor cache — hard refresh, brand new preview tabs each time
  • Revoked + re-granted the Google permission from scratch multiple times — identical result every time
  • Rebuilt the entire API Connector collection from scratch (new collection, every field re-entered) — identical result
  • Tested in both Development and Live

Evidence from the Network tab:
Watching the OAuth redirect chain in DevTools, Google DOES successfully redirect back to my /api/1.1/oauth_redirect endpoint with a valid one-time authorization code in the query string (confirmed present, HTTP 302). So the authorization step completes correctly — App ID, redirect URI, and scope are all accepted by Google. The failure has to be happening in the server-side exchange of that code for an access token, which I can’t inspect from the browser since it’s server-to-server.

What I need: since that exchange happens on Bubble’s infrastructure, could someone check the server logs for this app around a fresh test attempt, to see what Google’s token endpoint is actually returning during that exchange? Happy to reproduce it again and give an exact timestamp.

Thanks!

Don’t do that. This will create conflict and error. Bubble wll add this autoamtically

When you run the Login with social network, did you get the popup that say you can now initialize API calls?

Also,keep in mind that API connector doesn’t refresh token (but only for API connector, not for user. This is handled by Bubble automatically)

Can you share your settings screenshot/screencast?