Configuring OAuth 2.0 for Google services (Youtube, BigQuery, etc.)

Hi everyone :wave: wanted to share information on connecting to Google services through OAuth 2.0, which can be a bit tricky.

I’ve copied a solution for setting up Google BigQuery. If you are connecting a different Google service, it likely uses the same OAuth 2.0 method. Please ignore parts of this that do not apply to your service, or replace them with the relevant Google Cloud information.

Getting set up

Go to your project dashboard at https://console.cloud.google.com/home/dashboard and click “Explore and enable APIs” under “Getting Started.”

  • Click on the BigQuery (or other service) API link, or click “+ Enable APIs and Services”
  • Search for and enable the API you wish to connect to
  • Click on Credentials
  • Click “+ Create Credentials” and choose “OAuth client ID”
  • Set up the name for your credentials by clicking “Create Consent Screen” and enter https://parabola.io/api/steps/generic_api/callback as a verified callback URL

Now, you should have a client_id and client_secret.

In Parabola, open the Pull from an API step and select the OAuth 2.0 option from the Authorization tab. Click the blue Authorize button.

You will now see a form with three parts:

Part 1

Enter this URL: https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR-CLIENT-ID&redirect_uri=https%3A%2F%2Fparabola.io%2Fapi%2Fsteps%2Fgeneric_api%2Fcallback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery&access_type=offline&response_type=code&prompt=consent

Replace the value that follows “client_id” with your actual client_id, and replace “bigquery” with the name of the service you are trying to connect to.

Part 2

Enter this URL: https://www.googleapis.com/oauth2/v4/token

For the Access Token Request Body, enter these 4 pairs:

Replace the values for the last two with your actual client_id and client_secret.

Part 3

Use the same URL as part 2, and in the body, send the following:

  • grant_type : refresh_token
  • client_id : your client id
  • client_secret : your client secret

Replace the values for the last two with your actual client_id and client_secret.

Final Steps

  • Click the blue Authorize button at the bottom of the form, and a pop up window should appear asking if you would like to connect Parabola to your Google account
  • Click on the account that you want to connect (if it prompts you), and it will show you a warning that “This app isn’t verified”
  • Click the “Continue” button, and then allow Parabola access to the service
  • Click on “Allow” to create authorize the connection
  • It may ask you to verify which project you’d like to connect - choose the project and confirm

After all of that, you should be returned to Parabola, and can now access your Google’s APIs. Feel free to comment specific questions below, and we are happy to help you configure these connections!

Note: We know this documentation is not perfect, and we are continually updating this information :slight_smile: any and all suggestions are welcome!

4 Likes

Hi thanks for this, can i use this to write into Google Users, Groups. etc …
This is excellent news if it works. So good
It can help us create Google classes for teachers, add students, OMG unbelievable, automate teachers & student email distribution groups.

I was under the impression that, since Client Credentials Oauth2.0 did not work this wouldn’t work as well

1 Like

Hi @ANTONY_RAPPAI,

Have you tried to authenticate to Google’s APIs using the method above?

Taking a look at Google’s documentation, nearly all of the authentication scenarios list the flow type of authorization code.

Give it a shot, and let us know how it pans out!

Hi, i just tested this, and this works, i had to look up the appropriate scope from here OAuth 2.0 Playground

I wouldn’t have been able to figure out the Google OAUTH without this post, so thank you

1 Like

Our pleasure @ANTONY_RAPPAI! Glad to hear you were able to get this set up.

Sounds like some really cool new use cases were unlocked!

Hi, quick question, i noticed i had to edit the API Creds and authorize with my Google Account every now and then, i wonder if this could be worked around or am i doing something wrong here.

Thanks
Anto

Hey @ANTONY_RAPPAI,

Did you receive any error codes when pulling in your data? Double-check Part 3 of your setup to ensure your grant_type is set up correctly

My guess is that your access token is expiring but your refresh token is not generating a new token to sustain your authorization.

If it’s easiest, feel free to send us an email at help@parabola.io and we can look at your settings together.

I have followed the above, but i am getting the following error. Not sure what. I have missed here?

An error occurred during authorization: Access token URL returned a 405 when making a request for the access token. More data here: b’\n\n

Method Not Allowed

\n

The method is not allowed for the requested URL.

\n’

Hey @Damien_Kelly,

Our API documentation shares a bit of information on common error messages, and includes this section on 405 errors:

If you are using a Pull from an API or an Enrich with an API step, you are using the GET method. Your resource may require something like a POST , which can only be done with an API Export. Similarly, if you are using a POST , but it should be a PUT , you may get this error.

Check your APIs documentation to ensure that the resource you are requesting is compatible with the verb that you are using to make the request.

Does this seem like it could be the issue?

Hi, I need help to more efficiently pull entire tables from BigQuery. Right now, Im doing it through two very step-intensive Table Flips. The problem is that this doesnt work with larger tables, as there will be more than 1000 columns temporarily. How could I more directly pull an entire table (table schema and rows) from BigQuery?

Hey @Tiberius,

Totally understand why you’re using the “Flip Tables” step here. We should be able to change our approach to eliminate the need for flipping your large table of data.

I explain my recommended approach in detail in this Loom video.

At a high-level, we will first create a ‘template table’ by getting our headers in the proper order in a table with 0 rows.

Example Columns Response from BigQuery:

Screen Shot 2021-10-20 at 11.24.05 AM

Final Table Template

Screen Shot 2021-10-20 at 11.24.18 AM

The order of these columns should align with the order of the rows data returned from BigQuery:

Example Rows Response from BigQuery:

Once everything is ‘lined up’, we can use a “Stack Tables” step to create our final table:

Notice that the Match up data by column names box is purposely left unchecked so that the data ‘falls into place.’ It is very important to make sure everything is properly lined up before this stack.

Let me know how this approach works out for you!

1 Like

That works very well, thank you! Was missing that Stack Tables approach.

1 Like