2 API Connector/Ing Questions

First question: in the body of the API connector, is that code always going to be JSON? I am really confused at connecting to APIs and using them. Google and Twilio for instance, provide code to talking to their API, but not the JSON format. Am I missing something fundamental here? I am trying to use API connector to allow for the creation of Google Calendar events and I have no clue how to talk to their API. Can I just send JSON over? I know a little bit of PHP and feel comfortable writing in it, I just have so far never succeeded with the API connector, (except with Etsy and Math.js, as seen in the tutorials). It seems like something is not clicking here (in my head).

In a related issue, I’m trying to validate my FB messenger and can’t due to a restraint. FB sends a few querystring values to validate you. I was wondering if it was on any timeline. Here’s my original thread with more information. George told me to tag @emmanuel re: this, though I’ve already been pretty annoying about it.

1 Like

I’m having the same problem here.

I would like to create a new calendar entry for the logged in user (who is logged in via the google authentication method).

Can i use the already established google connection of that user to create a new date in his google calendar?
How can i connect this user to his google calendar via the api connector plugin?

It seems i do not really grasp the concept of the api connector, but i’m on it… Anyway, a little help would be appreciated to get started.

Short answer … yes you can.

You can use a Google auth token with the correct scope to call the Calendar API using API connector.

Longer answer … Without a lot of effort it is currently very difficult to do this. Bubble doesn’t have the OAUTH token that is required. You would have to get it yourself. I am midway through a test of a way to do this , and have got the token back.

Wow cool, thanks @NigelG, sounds very promissing! I’m happy to hear its possible and i’m totally ready to immerse myself in it. I’m sure i’ll need a lot of api interaction for my project ideas anyway, so there is no way around it for my part.

If you have any further hints you can share, i would appreciate this very much. I feel that i’m still quite far away from finding the solution by myself.

Btw: here is another post by @geoff.byron, who is asking for the same thing basically:

Maybe the topic should be collected somewhere to join forces.

Thanks, Jeremias

1 Like

Ok, well here is where I got to …

I am using AUTH0 for the heavy lifting of signups, it makes it a little easier I think. Although I think you could do the Google one yourself. Auth0 means you can add multiple social signons if need be.

Bubble’s API connector doesn’t help us, as there isn’t a response, it is a redirect.

You can see it in action here…

So I have a button that redirects to an External URL (which is just the API).

This runs the Google Logon (via Auth0) and brings you back to page on my app.

Here is the first problem … Bubble won’t extract the parameters from the URL, because of the “#”

If we can solve that, then you take the Access Token (a JWT - JSON Web Token) and then somehow decode it.

Once decoded you get the Google logon details.

{
“_id”: “12bdf73a9ad1a2864b2cb13e842679cc”,
“email”: "blah.blah@gmail.com",
“email_verified”: true,
“name”: “Nigel Godfrey”,
“given_name”: “Nigel”,
“family_name”: “Godfrey”,
“picture”: “https://lh3.googleusercontent.com/-jc2JJe1jmrw/AAAAAAAAAAI/AAAAAAAAE9Y/vt56M6XVQOM/photo.jpg”,
“gender”: “male”,
“locale”: “en-GB”,
“clientID”: “trUqPQrbNmWYg2i1eNIwDpw4EychRGjq”,
“updated_at”: “2016-06-18T13:27:30.324Z”,
“user_id”: “google-oauth2|105343519765682720291”,
“nickname”: “nigel.godfrey”,
“identities”: [
{
“provider”: “google-oauth2”,
“access_token”: “ya29.CjAFA543zc2KtwCKclK2MT-jRwdQPrXV2whehkpKsX4VlWFd931v0C0OleVZesnaWM0”,
“expires_in”: 3599,
“user_id”: “105358519765682732291”,
“connection”: “google-oauth2”,
“isSocial”: true
}
],
“created_at”: “2016-05-13T12:01:44.053Z”,
“global_client_id”: “JoPNL9S8AHS232IlxcFeRxk70fkppihW”,
“iss”: “https://biij.eu.auth0.com/”,
“sub”: “google-oauth2|105358519765632720291”,
“aud”: “X4UqPQrb32WYgxi1eNIwDpw4EychRGjq”,
“exp”: 1466292450,
“iat”: 1466256450
}

You can then use the Access Token to call Google Calendar.

But for now that is a dead end, I can’t decode the token in bubble. And I doubt using an API is a good idea.

There is probably an AUTH0 plugin that bubble could use. I think this would be a useful way to get OAUTH working.

2 Likes

Can we use some easy Regular Expression in Bubble to replace some part? or to sponsor this feature?

1 Like

Thanks for the effort @NigelG, it will take some time for me to dive into this for sure. Lets see if there will be an AUTH0 plugin for bubble anytime soon.

Yes, or at least a way to do OAUTH within Bubble. Hopefully that will come soon.

I’m working to figure out how to do this as well. Specifically to get Google Calendar to sync.

Not sure whether anyone has figured it out, but there is a very hacky way of extracting it which is this:
Screenshot 2021-09-07 at 14.00.42

1 Like