Create BigQuery data sources using different authentication methods
note
You need to create and open a project from the Welcome Screen. Only after that you will see the DataGrip interface and will be able to create connections.
For full information about BigQuery, refer to the official documentation.
BigQuery is a REST-based web service that allows you to run complex analytical SQL-based queries under large data sets.
To create a BigQuery data source and test the connection, you can use the following approaches:
When you use authorization with the Google user account, you need to receive the authorization code in a web browser.
To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
In the main menu, go to File | New | Data Source and select BigQuery.
In the Database Explorer ( View | Tool Windows | Database Explorer) , click the New icon () in the toolbar. Navigate to Data Source and select BigQuery.
Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.
Location for the downloaded JDBC drivers is the DataGrip configuration directory.
You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.
If there is no Download missing driver files link, then you already have the required drivers.
From the Authentication list, select Google User Account.
In the Project ID field, type the project ID.
Usually, it is a part of the service account email that goes after the at sign (
@
). For example,bigqueryproject-322409
. For the project ID's format, refer to the official instructions on creating a service account.From the Authorization Code Required dialog, cut the URL, paste it into the address bar of your web browser, and press to follow the URL.
Authorize access to your BigQuery application in your Google account.
Copy the authorization code received from Google, paste it in the Authorization Code Required dialog, and click OK.
Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.
In case of any connection issues, refer to the Cannot connect to a database page.
(Optional) By default, only the default project and dataset are introspected and available to work with. If you also want to work with other projects and datasets, in the Schemas tab, select them for the introspection.
Click OK to create the data source.
Find your new data source in Database Explorer () .
For more information about Database Explorer, see the corresponding reference topic.
tip
To see more projects and datasets under your new data source node, click the N of M button and select the ones you need. DataGrip will introspect and show them.
For more information about displaying projects and datasets in Database Explorer, refer to the Show all databases or schemas tutorial.
For more information about working with database objects in DataGrip, refer to Database objects.
To write and run queries, open the default query console by clicking the data source and pressing .
To view and edit data of a database object, open Data editor and viewer by double-clicking the object.
For authorization, the BigQuery driver uses data from a special credentials file — a service account key file. By default, the path to the file is ~
You can set a custom location for the credentials file by using the GOOGLE_APPLICATION_CREDENTIALS
environment variable. Alternatively, set the path to the credentials file in the Service account key file field.
To generate the service account key file for the connection, you need to create a Google Cloud Platform service account.
Create a service account by following the official instructions.
On the Grant this service account access to the project step in the wizard, select roles for this service account.
For example, for read-only access, select BigQuery Data Viewer, BigQuery Job User, and BigQuery User from the BigQuery menu. Alternatively, select BigQuery | BigQuery Admin for access to all resources within the project.
For more information about roles and permissions, refer to Predefined roles and permissions at cloud.google.com.
Generate and download the service account key file by following the official instructions.
To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
In the main menu, go to File | New | Data Source and select BigQuery.
In the Database Explorer ( View | Tool Windows | Database Explorer) , click the New icon () in the toolbar. Navigate to Data Source and select BigQuery.
Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.
Location for the downloaded JDBC drivers is the DataGrip configuration directory.
You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.
If there is no Download missing driver files link, then you already have the required drivers.
From the Authentication list, select Application Default Credentials.
In the Service account key file field, type the path to the JSON service account key file that you obtained on Step 1. Obtain credentials.
Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.
In case of any connection issues, refer to the Cannot connect to a database page.
(Optional) By default, only the default project and dataset are introspected and available to work with. If you also want to work with other projects and datasets, in the Schemas tab, select them for the introspection.
Click OK to create the data source.
Find your new data source in Database Explorer () .
For more information about Database Explorer, see the corresponding reference topic.
tip
To see more projects and datasets under your new data source node, click the N of M button and select the ones you need. DataGrip will introspect and show them.
For more information about displaying projects and datasets in Database Explorer, refer to the Show all databases or schemas tutorial.
For more information about working with database objects in DataGrip, refer to Database objects.
To write and run queries, open the default query console by clicking the data source and pressing .
To view and edit data of a database object, open Data editor and viewer by double-clicking the object.
For authorization, the BigQuery driver uses data from a special credentials file — a service account key file. By default, the path to the file is ~
You can set a custom location for the credentials file by using the GOOGLE_APPLICATION_CREDENTIALS
environment variable. Alternatively, set the path to the credentials file in the Key file field.
To generate the service account key file for the connection, you need to create a Google Cloud Platform service account.
Create a service account by following the official instructions.
On the Grant this service account access to the project step in the wizard, select roles for this service account.
For example, for read-only access, select BigQuery Data Viewer, BigQuery Job User, and BigQuery User from the BigQuery menu. Alternatively, select BigQuery | BigQuery Admin for access to all resources within the project.
For more information about roles and permissions, refer to Predefined roles and permissions at cloud.google.com.
Generate and download the service account key file by following the official instructions.
To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
In the main menu, go to File | New | Data Source and select BigQuery.
In the Database Explorer ( View | Tool Windows | Database Explorer) , click the New icon () in the toolbar. Navigate to Data Source and select BigQuery.
Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.
Location for the downloaded JDBC drivers is the DataGrip configuration directory.
You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.
If there is no Download missing driver files link, then you already have the required drivers.
From the Authentication list, select Google Service Account.
In the Service account email field, type the service account's name.
You can find the service account's name as Email on the Service accounts page (IAM & Admin | Service accounts) of the Google Cloud Platform. For more information about creating a service account for the name's format, refer to official instructions. The service account's name should look like this:
intellij-ide@bigqueryproject-322409.iam.gserviceaccount.com
.In the Project ID field, type the project ID.
Usually, it is a part of the service account email that goes after the at sign (
@
). For example,bigqueryproject-322409
. For the project ID's format, refer to the official instructions on creating a service account.In the Key file field, type the path to the JSON service account key file that you obtained on Step 1. Obtain credentials.
Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.
In case of any connection issues, refer to the Cannot connect to a database page.
(Optional) By default, only the default project and dataset are introspected and available to work with. If you also want to work with other projects and datasets, in the Schemas tab, select them for the introspection.
Click OK to create the data source.
Find your new data source in Database Explorer () .
For more information about Database Explorer, see the corresponding reference topic.
tip
To see more projects and datasets under your new data source node, click the N of M button and select the ones you need. DataGrip will introspect and show them.
For more information about displaying projects and datasets in Database Explorer, refer to the Show all databases or schemas tutorial.
For more information about working with database objects in DataGrip, refer to Database objects.
To write and run queries, open the default query console by clicking the data source and pressing .
To view and edit data of a database object, open Data editor and viewer by double-clicking the object.
To connect to the BigQuery database by using the Access and Refresh Tokens authentication method, the following credentials are required: client ID and client secret, refresh and access tokens.
When you use OAuth 2.0 for authentication, your users are authenticated after they agree to terms that are presented to them on a user consent screen. The OAuth consent screen is a dialog that displays a notification about who requests access to the user's data and a type of this data.
Before you generate a client ID and a client secret, you need to configure the OAuth consent screen.
Create OAuth consent screen by following the official instructions.
For more information about user consent, refer to the User consent section at support.google.com
Get a client ID and a client secret by following the official instructions.
For the URI, use the following one:
https://developers.google.com/oauthplayground
Find your client ID and client secret in the OAuth client created window. Alternatively, you can click the created OAuth client ID configuration and get your credentials here.
Having a client ID and a client secret, you can generate authorization code and tokens. To do that, perform the following steps:
Open the OAuth 2.0 Playground in a separate browser tab.
Click the OAuth 2.0 Configuration icon, select the Use your own OAuth credentials checkbox.
Paste your client ID and client secret in OAuth Client ID and OAuth Client secret fields.
Click Close in the OAuth 2.0 Configuration window.
In the wizard on Step 1. Select & authorize APIs, select BigQuery API v2 | https://www.googleapis.com/auth/bigquery.
Click Authorize APIs.
Follow the wizard in a browser and give permissions to the application.
On Step 2 Exchange authorization code for tokens, click Exchange authorization code for tokens.
Copy received refresh and access tokens.
To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
In the main menu, go to File | New | Data Source and select BigQuery.
In the Database Explorer ( View | Tool Windows | Database Explorer) , click the New icon () in the toolbar. Navigate to Data Source and select BigQuery.
Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.
Location for the downloaded JDBC drivers is the DataGrip configuration directory.
You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.
If there is no Download missing driver files link, then you already have the required drivers.
From the Authentication list, select Access and Refresh Tokens.
In the Project ID field, type the project ID.
Usually, it is a part of the service account email that goes after the at sign (
@
). For example,bigqueryproject-322409
. For the project ID's format, refer to the official instructions on creating a service account.In the Access token field, paste your access token.
In the Refresh token field, paste your refresh token.
In the Client ID field, paste your client ID.
In the Client secret field, paste your client secret.
Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.
In case of any connection issues, refer to the Cannot connect to a database page.
(Optional) By default, only the default project and dataset are introspected and available to work with. If you also want to work with other projects and datasets, in the Schemas tab, select them for the introspection.
Click OK to create the data source.
Find your new data source in Database Explorer () .
For more information about Database Explorer, see the corresponding reference topic.
tip
To see more projects and datasets under your new data source node, click the N of M button and select the ones you need. DataGrip will introspect and show them.
For more information about displaying projects and datasets in Database Explorer, refer to the Show all databases or schemas tutorial.
For more information about working with database objects in DataGrip, refer to Database objects.
To write and run queries, open the default query console by clicking the data source and pressing .
To view and edit data of a database object, open Data editor and viewer by double-clicking the object.