Unable to refresh token for gmail in Live

I’ve got a Gmail API set up in Bubble using OAuth2 User-Agent Flow. It was working perfectly before, but recently started returning a 401 Invalid Credentials error. The connector shows “Your token is not valid any more. You should sign up again in run mode,” but when I click my “Connect Gmail” button, the Google OAuth popup doesn’t appear — it just throws the same 401 error.

The connector is fully configured with correct App ID, secret, scopes, and redirect URLs. It uses https://oauth2.googleapis.com/token and https://accounts.google.com/o/oauth2/v2/auth. I know the token has simply expired, but Bubble isn’t launching the OAuth flow to refresh it.

Has anyone seen this before, and how can I force Bubble to prompt the Google sign-in again to refresh the token without rebuilding the whole connector?

Revoke the token manually from your Google account: https://myaccount.google.com/connections

Find your app’s name in the list of 3rd party connections, click on it, then “delete connection.”

Then try running the OAuth flow again in your app.

Thanks, tried that but unfortunatley still getting:

There was an issue setting up your call.

Raw response for the API
Status code 401
{
“error”: {
“code”: 401,
“message”: “Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.”,
“errors”: [
{
“message”: “Invalid Credentials”,
“domain”: “global”,
“reason”: “authError”,
“location”: “Authorization”,
“locationType”: “header”
}
],
“status”: “UNAUTHENTICATED”
}
}

Do you have your app’s live domain in the Google console settings where you created your OAuth credentials?

Did you set offline in your request (Are you using the Bubble user-agent flow)? Without it, Google doesn’t provide refresh token…

1 Like

Yes I believe so. See below. Does anything look strange?

Yes I believe so. See below. Does anything look strange?

Image for Bubble messageboard

Are you talking about refresh token in api connector itself or for your user?

Either

At the moment Im just testing. But it doesnt work when I reinitialise or when I try in test mode

Bubble doesn’t refresh token for API connector itself, only for “real” user (not the user you used to initialize the API connector). Test with a real user without debug mode.

THanks for the response.

I have tried testing with a real user without debug more, but still in preview/test mode. Does it need to be Live/Deployed?

No it should work on both version.

Do you use more than one user-agent auth?

No I don’t believe so.

Do you mean just for that API or do I use user-agent auth across multiple API’s?

I never managed to sort this, could anyone help please?