Google oauth token not being sent with all requests

I am building out API calls to the Google calendar.

I am using the social login feature.

I am having difficulties now with some of my API calls being returned with error saying that they’re not authenticated or that identification is missing from the header.

So far I am able to login, call all of my calendar events, Paul profile information, and poll information related to my calendar colors. However, when I try to create update or delete an event I receive an error that says I am not authenticated. This is that error:

    {
  "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"
  }
}

It’s just weird because half of the calls seem to get authenticated and the other half do not. This is very reliable behavior and I have seen nothing else. And my first thought would be well Jared, didn’t you check to make sure that they work in the builder. Yes I did. When I do these calls from within the API builder itself I first authenticate and then am able to create events, read Events, update and delete Events with no issue.

It’s only in the preview and live versions of the app that I can’t do these three actions. Create. Update/patch. Delete

Shots of the api calls for reference

The main setup which works fine


The scope being requested


    https://www.googleapis.com/auth/calendar profile email

A read (GET) call which works fine

The update call which works fine in the builder but not any live version of the app even after authenticating.

Are you logged in with a user that is authenticate in Bubble using Google oAuth2 when you do request in live or preview mode?

1 Like

Thanks for the input @Jici I think i am logged in the right way.
i login and then send a list from the authenticated API call to a RG (this part seems to work fine)

Here is the login WF


the issue comes when i try to call the update endpoint. what i dont understand is why this part works in the builder but not here.

when i run this workflow in preview (meaning i did authenticate and recieve calendar events for my logged in user) i get this error which is easier to read above

I was looking at the plugin that was referenced in the other post… I think it’s missing an events scope

https://www.googleapis.com/auth/calendar.events

Currently it’s only referencing the calendar https://www.googleapis.com/auth/calendar

1 Like

Maybe related to scopes?
It’s strange that this work in API Connector.
But I can see you are creating a plugin. So not sure if this can be related.
Try to publish as private and add it to a private app and check if this work.
Also, remove any test value your have in API Connector.
Idon’t think you can see the full request in Logs (advanced, check box for requests and plugins). If this is the case, it may help you check what is provided by Bubble. But pretty sure it’s not available

2 Likes

Sorry @Jici, didn’t mean to cut in front of ya :stuck_out_tongue_winking_eye:

1 Like

i thought scopes too at first, but the /calendar scope should provide all access i want…at least that’s what i thought until i read the above from @lantzgould what’s more weird to me is that the other 3 endpoints i created under the same main API call work just fine with no issue about scope or authentication. just those three give me that error.

i tried to add the .events part and got a different set of permissions only more restrictive. For example I could no longer access calendar colors endpoint .

Seems /calendar is the main endpoint I’d want.

Maybe because it’s an unverified website with google Idk :man_shrugging:

1 Like

Strange that it initializes in the editor but errors in run time.

What if you have two of them in there?

Scope: https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events profile email (include the spaces)

My inner ocd is making me want to just set up a plugin and test for myself haha.

1 Like

I’d be happy to add you on to this plugin, it’s not much special. it seems strange to me though, too. like it gets confused when it gets over to the actual app

how would you add a second scope like that? right in line, the first URL followed by the second?

Correct, you just can paste the whole snippet above into the scope field. Each scope is separated with a space.

You can invite others to a plugin here:

I’ll try my own first before bothering you with yours though lol :slightly_smiling_face:

2 Likes

adding both scopes didnt do the trick. still getting the same issue.

works in the plugin builder but not on the app page.

I’m making progress.

now im getting a 400 error instead of 401 :rofl:

:relaxed: :relaxed:

I got it working! Super pumped!!!

now you can grab your google apointments from my fullcal plugin, move them around/edit as needed, and reflect the updates in your google cal.

now to work out the funny kinks!

2 Likes

Did you find out what was causing that?

… not exactly. i think it was a mixture of a space in my scopes that shouldnt have been there and then it was a matter of switching from PUT to PATCH but i think in this case it doesnt really matter.

1 Like

Gotcha. Glad you got it sorted out :+1:

1 Like

Thanks for the input! I think it did require that second scope being added also. Thanks a lot you guys @Jici and @lantzgould

You probably have calendars and google cal plugins already, but if not, i’d be happy to donate mine to one of your apps for your time!

2 Likes

I now have read, update, and delete all working fine. still working out kinks with create.

again, easy int he plugin builder. takes different finesse in the app

only down to cleaning up this final formatting!

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid time zone definition for start time."
   },
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid time zone definition for end time."
   }
  ],
  "code": 400,
  "message": "Invalid time zone definition for start time."
 }
}
2 Likes

Is this just using a standard timezone format of America/Los_Angeles, for example?

yeah. not sure what’s going on with my fat fingers today, they keep entering whatever they want into these damned api calls but i’m about to publish the CRUD capablities! just adding in the final touches for today

1 Like

:laughing: nice