Set up the BigQuery environment¶
The BigQuery connector allows you to access the BigQuery REST API from an integration sequence.
To work with the BigQuery connector, you need to have a Google Cloud Platform account. If you do not have a Google Cloud Platform account, go to console.cloud.google.com, and create a Google Cloud Platform trial account.
BigQuery uses the OAuth 2.0 protocol for authorization. All requests to the BigQuery REST API will be authorized against a registered user. Developers can generate user credentials from the Google Cloud Platform using two different mechanisms. See the following sections for details.
Obtain user credentials¶
Follow the steps below to generate user credentials.
Obtaining a client ID and client secret
-
Go to https://accounts.google.com/SignUphttps://accounts.google.com/SignUp and create a Google account.
-
Go to https://console.developers.google.com/projectselector/apis/credentials, and sign in to your Google account.
-
If you do not already have a project, Enter
BigQueryExample
as the name of the project and click on Create. -
To create an
api key
, Click on Create credentials and then select API key. -
Click on the Configure consent screen in the next screen.
-
Provide the Application Name as
BigQueryExample
, and provide your email asUser support email
andemail address of Developer contact information
in the Consent Screen, then click on SAVE AND CONTINUE. -
To add scopes for API, click on ADD OR REMOVE SCOPES
-
Go to Google API Library.
-
Search BigQuery API and enable it.
-
Refresh the page and add following scopes.
-
-
Click on ADD USERS, type the email address of the account you will be testing with, then click on SAVE AND CONTINUE.
-
To get
client id
andclient secrets
, Click on Create credentials and then select OAuth client ID. -
Next, select Web Application, and create a client.
-
Add
https://developers.google.com/oauthplayground
as the redirect URI (you can add any URI that you need as redirect URI) under Authorized redirect URIs, and then click Create. This displays the client ID and client secret. -
Make a note of the client ID and client secret that is displayed or download the json file, and then click OK.
Obtain access token and refresh token¶
-
Navigate to OAuth 2.0 Playground and click OAuth 2.0 Configuration button in the Right top corner.
-
Select Use your own OAuth credentials, and provide the obtained Client ID and Client Secret values as above click on Close.
-
Under Step 1, select
BigQuery API v2
from the list of APIs, select the following scopes. -
Click on Authorize APIs button and select your Gmail account when you are asked and allow the scopes.
-
Under Step 2, click Exchange authorization code for tokens to generate and display the Access Token and Refresh Token.
Obtain credentials using the service account¶
-
Open the Service Accounts page in the GCP console.
-
Select your project and click Open.
-
Click Create Service Account.
-
Enter Service account details, and then click CREATE AND CONTINUE.
-
Select a role you wish to grant to the service account and click CONTINUE.
-
Grant users access to this service account (optional) and click Done.
-
Go to the service account for which you wish to create a key and click on the created Service account in that row.
-
Click on Create key.
-
Select the key type as P12 and click Create. Then the created key will be downloaded.
Create dataset and table¶
Create dataset
-
Open the BigQuery console and select the created project
-
Click on the View Action on the created project.
-
Enter the required Dataset details and click Create Dataset.
Create table
-
After creating the Dataset, click on the created Dataset. You can see the following details. Then click Create Table.
-
Enter required Table details and click Create.
For more information about these operations, please refer to the BigQuery connector reference guide.