Skip to main content

Connecting to Google BigQuery (OAuth, JWT)

Introduction

In this article, we're going to show you how to connect your Astrato workspace to a data source in Google BigQuery.

Checklist

Before you can set up your data connection, you'll need the following:

  • Data connection: project and dataset names.

  • User account: Enter your username and password when asked. If you are using a Google account, when you log in, Google will prompt you to consent to Astrato accessing your Google Workspace.

  • Any user who uses the connection needs these permissions in BigQuery:

    • bigquery.jobs.create This permission allows creating and running query jobs on the project level. It is included in predefined roles such as BigQuery Job User.

    • bigquery.tables.get Data Permission on all tables and views referenced in the query grants read access to the data in those tables and views. It is included in the BigQuery Data Viewer role.

How to set necessary permissions in BigQuery

The best way is to use a Google Cloud service account to log in and make a safe connection to BigQuery.

Create a Service Account

  1. In the Google Cloud Console, navigate to the project where your BigQuery instance is located.

  2. Go to IAM & Admin → Service Accounts, then click Create Service Account.

  1. Click the Create and Continue button under the 1-step section to proceed with the service account setup.

  2. Grant the service account the following minimum set of permissions:

    1. BigQuery Connection Service Agent

    2. BigQuery Data Viewer

    3. BigQuery Job User

Click Done to complete the setup.

Creating a data connection to Google BigQuery

  1. Select Data + AI in the Astrato sidebar and go to the Data Connection tab. Click on New connection to open the screen with available data connection providers. Click the Google BigQuery icon to start.

  1. Select one of the available authentication options: OAuth or JWT Token.

OAuth - Allow Astrato permission to access external data

You can use the already defined default OAuth connection or define your own.

After selection, Astrato checks whether you already have an integration with Google BigQuery; if not, it displays a message that permission is required.

  • Click Confirm to continue.

  • The Google authentication page appears; select the account you want to use, review the required permissions, and click Continue.

These are the 3 services to which Astrato has access.

  • If the user account authentication is successful, Astrato displays the message that permissions are granted. Click OK to continue.

OAuth - Enter data connection and project details

  1. Enter the details (project name, dataset name) and click Next. This completes the data connection process.

  1. The only thing to establish before you go to The Semantic Layer Editor in Astrato is accept or modify access to the created data connection for Astrato users and /or groups.

How create a JWT (a Service Account Key)

With the JWT authentication method, a Google Cloud service account is used to authenticate and establish a secure connection to BigQuery.

The JWT method is recommended for server-to-server integrations, as it avoids manual user authentication and ensures reliable, automated access to your BigQuery datasets.

The service account key will be used by Astrato to establish the connection with Google BigQuery.

  1. In the Google Cloud Console, go to IAM & AdminService Accounts.

  2. Select the service account created in the previous step.

  3. Navigate to the Keys tab, then click Add KeyCreate New Key. Ensure the Key type is set to JSON.

The key file will be generated and automatically downloaded to your computer. Store this file securely, as it will be required for the Astrato connection

JWT - Enter data connection details

  1. Once you've selected the data connection, slide the toggle to the right to select JWT Token.

  1. Enter the details (JSON key, dataset) and click Next.

  1. Set the data connection name, then click Next.

  1. The only thing to establish before you go to The Semantic Layer Editor in Astrato is accept or modify access to the created data connection for Astrato users and /or groups.

JWT- Dynamic Data Connection

A dynamic data connection allows users to work on different projects using a single data model. This is especially useful when combined with embedded analytics for OEM solutions.

Setting up a dynamic data connection is similar to setting up a JWT connection.

Follow these steps:

  1. Create a new BigQuery connection (check the use dynamic connection checkbox)​

  2. Paste the JWT key

  3. Select the default project (this will be the default project to build the data model and define measures and dimensions)

  4. Select the dataset to use. This part is not dynamic, and all users will use the same dataset.

  5. Click next ​​

  6. Add more users (who must be part of the Astrato tenant) to the connection settings. Define the authentication key and the project to use for each user's connection.​

  7. Click next

  8. Give the data connection a name.

  9. Define who has the right to use the connection.

10. Click connect

Known Limitation

  • Only users who use the same JWT key and project as the defaults will be able to edit and see the data in the Semantic Layer Editor

  • The dynamic data connection is only used in published workbooks.

  • Users who aren't defined in the dynamic connection table won't be able to see data in the workbook.

Did this answer your question?