# Create Google BigQuery data sources using different authentication methods

Procedure: Enable the Database Tools and SQL plugin

This functionality relies on the  Database Tools and SQL plugin, which  is bundled and enabled in IntelliJ IDEA   by default. If the relevant features are not available, make sure that you did not disable the plugin.

> **Note:**
> Database Tools and SQL functionality support is limited in IntelliJ IDEA without the Ultimate subscription.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

Procedure: Official documentation

* For full information about Google BigQuery, refer to [the official documentation](https://cloud.google.com/bigquery/docs).

Google BigQuery is a REST-based web service that allows you to run complex analytical SQL-based queries under large data sets.

To create a Google BigQuery data source and test the connection, you can use the following approaches:

* [Using Google user account](#google-user-account)

* [Using Google service account](#google-service-account)

* [Using application default credentials](#application-default-credentials)

* [Using access and refresh tokens](#connecting-with-access-and-refresh-tokens-oauth-2-0)

## Google user account

When you use authorization with the Google user account, you need to receive the authorization code in a web browser.

Procedure: Connect to Google BigQuery

To connect to a database, create a data source that will store your connection details.

1. Select the data source you want to create. You can do this using one of the following ways:

* In the main menu, go to `File | New | Data Source` and select Google BigQuery.

* In the Database tool window , click ![the New icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) New on the toolbar. Navigate to Data Source and select Google BigQuery.

![Create a new data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_new_data_source.png)

2. 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](https://www.jetbrains.com.cn/en-us/datagrip/jdbc-drivers/) page.

![The Download missing driver files link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_download_missing_drivers_link.png)

Location for the downloaded JDBC drivers is the [IntelliJ IDEA configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-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](jdbc-drivers.html#configure_a_jdbc_driver_for_an_existing_data_source).

If there is no Download missing driver files link, then you already have the required drivers.

3. From the Authentication list, select Google User Account.

4. 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](https://cloud.google.com/iam/docs/service-accounts-create).

5. From the Authorization Code Required dialog, cut the URL, paste it into the address bar of your web browser, and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) to follow the URL.

6. Authorize access to your Google BigQuery application in your Google account.

7. Copy the authorization code received from Google, paste it in the Authorization Code Required dialog, and click OK.

8. Ensure that the database connection can be established using the provided details. To do this, click the Test Connection  link at the bottom of the connection details section.

![Test Connection link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_test_connection_link.png)

If you encounter any connection issues, refer to the [Cannot connect to a database](connectivity-problems.html) page.

9. (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.

![Schemas tab of the Data Sources and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_schemas_tab.png)

10. Click OK to create the data source.

11. Find your new data source in the    Database   tool window   .

* For more information about the Database tool window , see the corresponding [reference topic](database-tool-window.html). > **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. IntelliJ IDEA will introspect and show them. > > > > ![Select databases and schemas to introspect and display in the Database tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/connection_flow_show_databases_and_schemas.png)

* For more information about working with database objects in IntelliJ IDEA, refer to [Database objects](database-objects.html).

* To write and run queries, open the default [query console](query-consoles.html) by clicking the data source and pressing `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* To view and edit data of a database object, open [Data editor and viewer](data-editor-and-viewer.html) by double-clicking the object.

[Video](https://resources.jetbrains.com.cn/help/img/idea/2026.2/application_default_credentials.json`.

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](https://cloud.google.com/iam/docs/service-accounts).

Procedure: Step 1. Obtain credentials file

1. Create a service account  by following the [official instructions](https://cloud.google.com/iam/docs/service-accounts-create#creating).

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 Google BigQuery Data Viewer, Google BigQuery Job User, and Google BigQuery User from the Google BigQuery menu. Alternatively, select `Google BigQuery | Google 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](https://cloud.google.com/bigquery/docs/access-control).

2. Generate and download the service account key file  by following the [official instructions](https://cloud.google.com/iam/docs/keys-create-delete#creating).

Procedure: Step 2. Connect to Google BigQuery

To connect to a database, create a data source that will store your connection details.

1. Select the data source you want to create. You can do this using one of the following ways:

* In the main menu, go to `File | New | Data Source` and select Google BigQuery.

* In the Database tool window , click ![the New icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) New on the toolbar. Navigate to Data Source and select Google BigQuery.

![Create a new data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_new_data_source.png)

2. 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](https://www.jetbrains.com.cn/en-us/datagrip/jdbc-drivers/) page.

![The Download missing driver files link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_download_missing_drivers_link.png)

Location for the downloaded JDBC drivers is the [IntelliJ IDEA configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-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](jdbc-drivers.html#configure_a_jdbc_driver_for_an_existing_data_source).

If there is no Download missing driver files link, then you already have the required drivers.

3. From the Authentication list, select Application Default Credentials.

4. 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](#obtain_credentials_adc) .

5. Ensure that the database connection can be established using the provided details. To do this, click the Test Connection  link at the bottom of the connection details section.

![Test Connection link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_test_connection_link.png)

If you encounter any connection issues, refer to the [Cannot connect to a database](connectivity-problems.html) page.

6. (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.

![Schemas tab of the Data Sources and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_schemas_tab.png)

7. Click OK to create the data source.

8. Find your new data source in the    Database   tool window   .

* For more information about the Database tool window , see the corresponding [reference topic](database-tool-window.html). > **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. IntelliJ IDEA will introspect and show them. > > > > ![Select databases and schemas to introspect and display in the Database tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/connection_flow_show_databases_and_schemas.png)

* For more information about working with database objects in IntelliJ IDEA, refer to [Database objects](database-objects.html).

* To write and run queries, open the default [query console](query-consoles.html) by clicking the data source and pressing `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* To view and edit data of a database object, open [Data editor and viewer](data-editor-and-viewer.html) by double-clicking the object.

![Connecting with Application Default Credentials](https://resources.jetbrains.com.cn/help/img/idea/2026.2/application_default_credentials.json`.

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](https://cloud.google.com/iam/docs/service-accounts).

Procedure: Step 1. Obtain credentials file

1. Create a service account  by following the [official instructions](https://cloud.google.com/iam/docs/service-accounts-create#creating).

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 Google BigQuery Data Viewer, Google BigQuery Job User, and Google BigQuery User from the Google BigQuery menu. Alternatively, select `Google BigQuery | Google 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](https://cloud.google.com/bigquery/docs/access-control).

2. Generate and download the service account key file  by following the [official instructions](https://cloud.google.com/iam/docs/keys-create-delete#creating).

Procedure: Step 2. Connect to Google BigQuery

To connect to a database, create a data source that will store your connection details.

1. Select the data source you want to create. You can do this using one of the following ways:

* In the main menu, go to `File | New | Data Source` and select Google BigQuery.

* In the Database tool window , click ![the New icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) New on the toolbar. Navigate to Data Source and select Google BigQuery.

![Create a new data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_new_data_source.png)

2. 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](https://www.jetbrains.com.cn/en-us/datagrip/jdbc-drivers/) page.

![The Download missing driver files link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_download_missing_drivers_link.png)

Location for the downloaded JDBC drivers is the [IntelliJ IDEA configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-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](jdbc-drivers.html#configure_a_jdbc_driver_for_an_existing_data_source).

If there is no Download missing driver files link, then you already have the required drivers.

3. From the Authentication list, select Google Service Account.

4. 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](https://cloud.google.com/iam/docs/service-accounts-create). The service account's name should look like this: `intellij-ide@bigqueryproject-322409.iam.gserviceaccount.com`.

5. 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](https://cloud.google.com/iam/docs/service-accounts-create).

6. In the  Key file field, type the path to the JSON service account key file that you obtained on  [Step 1. Obtain credentials](#obtain_credentials_gsa).

7. Ensure that the database connection can be established using the provided details. To do this, click the Test Connection  link at the bottom of the connection details section.

![Test Connection link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_test_connection_link.png)

If you encounter any connection issues, refer to the [Cannot connect to a database](connectivity-problems.html) page.

8. (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.

![Schemas tab of the Data Sources and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_schemas_tab.png)

9. Click OK to create the data source.

10. Find your new data source in the    Database   tool window   .

* For more information about the Database tool window , see the corresponding [reference topic](database-tool-window.html). > **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. IntelliJ IDEA will introspect and show them. > > > > ![Select databases and schemas to introspect and display in the Database tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/connection_flow_show_databases_and_schemas.png)

* For more information about working with database objects in IntelliJ IDEA, refer to [Database objects](database-objects.html).

* To write and run queries, open the default [query console](query-consoles.html) by clicking the data source and pressing `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* To view and edit data of a database object, open [Data editor and viewer](data-editor-and-viewer.html) by double-clicking the object.

![Connecting with a Google Service Account](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connecting_to_bigquery_with_a_google_service_account_2021_3.png)

## Access and refresh tokens (OAuth 2.0)

To connect to the Google 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.

Procedure: Step 1. Obtain credentials

1. Create OAuth consent screen  by following the [official instructions](https://developers.google.com/workspace/guides/configure-oauth-consent).

For more information about user consent, refer to  [the User consent section at support.google.com](https://support.google.com/cloud/answer/6158849?hl=en#zippy=%2Cuser-consent)

2. Get a client ID and a client secret  by following the [official instructions](https://support.google.com/cloud/answer/6158849).

For the URI, use the following one:

```CURL
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.

3. Having a client ID and a client secret, you can generate authorization code and tokens. To do that, perform the following steps:

1. Open [the OAuth 2.0 Playground](https://developers.google.com/oauthplayground/) in a separate browser tab.

2. Click the OAuth 2.0 Configuration icon, select the Use your own OAuth credentials checkbox.

3. Paste your client ID and client secret in OAuth Client ID and OAuth Client secret fields.

![OAuth 2.0 Configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_o_auth_2_0_configuration.png)

4. Click Close in the OAuth 2.0 Configuration window.

5. In the wizard on Step 1. Select & authorize APIs, select `BigQuery API v2 | https://www.googleapis.com/auth/bigquery`.

6. Click Authorize APIs.

7. Follow the wizard in a browser and give permissions to the application.

![give permissions to the application](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_give_permissions_to_the_application.png)

8. On Step 2 Exchange authorization code for tokens, click Exchange authorization code for tokens.

9. Copy received refresh and access tokens.

![refresh and access tokens](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_refresh_and_access_tokens.png)

Procedure: Step 2. Connect to Google BigQuery

To connect to a database, create a data source that will store your connection details.

1. Select the data source you want to create. You can do this using one of the following ways:

* In the main menu, go to `File | New | Data Source` and select Google BigQuery.

* In the Database tool window , click ![the New icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) New on the toolbar. Navigate to Data Source and select Google BigQuery.

![Create a new data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_new_data_source.png)

2. 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](https://www.jetbrains.com.cn/en-us/datagrip/jdbc-drivers/) page.

![The Download missing driver files link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_download_missing_drivers_link.png)

Location for the downloaded JDBC drivers is the [IntelliJ IDEA configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-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](jdbc-drivers.html#configure_a_jdbc_driver_for_an_existing_data_source).

If there is no Download missing driver files link, then you already have the required drivers.

3. From the Authentication list, select Access and Refresh Tokens.

4. 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](https://cloud.google.com/iam/docs/service-accounts-create).

5. In the Access token field, paste [your access token](#refresh_access_tokens).

6. In the Refresh token field, paste [your refresh token](#refresh_access_tokens).

7. In the Client ID field, paste [your client ID](#client_id_client_secret).

8. In the Client secret field, paste [your client secret](#client_id_client_secret).

9. Ensure that the database connection can be established using the provided details. To do this, click the Test Connection  link at the bottom of the connection details section.

![Test Connection link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_test_connection_link.png)

If you encounter any connection issues, refer to the [Cannot connect to a database](connectivity-problems.html) page.

10. (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.

![Schemas tab of the Data Sources and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_schemas_tab.png)

11. Click OK to create the data source.

12. Find your new data source in the    Database   tool window   .

* For more information about the Database tool window , see the corresponding [reference topic](database-tool-window.html). > **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. IntelliJ IDEA will introspect and show them. > > > > ![Select databases and schemas to introspect and display in the Database tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/connection_flow_show_databases_and_schemas.png)

* For more information about working with database objects in IntelliJ IDEA, refer to [Database objects](database-objects.html).

* To write and run queries, open the default [query console](query-consoles.html) by clicking the data source and pressing `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* To view and edit data of a database object, open [Data editor and viewer](data-editor-and-viewer.html) by double-clicking the object.

![connecting with tokens](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connecting_with_tokens_2021_3.png)

## See also

### Reference

[Data sources and their elements](database-tool-window.html#icons-for-data-sources-and-their-elements) [Data Sources and Drivers dialog](data-sources-and-drivers-dialog.html)

### Tool Windows

[Database tool window](database-tool-window.html)

