# Authorize BigQuery

## Enabling Required Google APIs <a href="#id-1367fe36-76e9-430d-a949-7b538bc2ab00" id="id-1367fe36-76e9-430d-a949-7b538bc2ab00"></a>

The following APIs are required by the Stacksync services in order to access the data and create a sync in BigQuery:

1. [Cloud Run API](https://console.cloud.google.com/marketplace/product/google/run.googleapis.com) (to create a secure portal for real-time notification service in your space)
2. [Cloud Resource Manager API](https://console.cloud.google.com/marketplace/product/google/cloudresourcemanager.googleapis.com) (to set up all services)
3. [BigQuery API](https://console.cloud.google.com/marketplace/product/google/bigquery.googleapis.com) (this is where your data resides)
4. [Eventarc API](https://console.cloud.google.com/marketplace/product/google/eventarc.googleapis.com) (a notification service that enables real-time updates to happen)

#### 1. Open <https://console.cloud.google.com/apis/library>

#### 2. Search for the API "cloud run API"

<figure><img src="/files/1CxUkMBe0KAWU4357ecZ" alt=""><figcaption></figcaption></figure>

#### 3. Click on the API "Cloud Run API"

<figure><img src="/files/EZPf58AWEYL31MIQ7L3s" alt=""><figcaption></figcaption></figure>

#### 4. Enable the API

<figure><img src="/files/9QvX0IAqS7sbZhH9Qffm" alt=""><figcaption></figcaption></figure>

#### 5. Repeat Steps 2-3 for the following APIs

Cloud Resource Manager API

<figure><img src="/files/Ijk8p4L76LA0ztnih7mm" alt=""><figcaption></figcaption></figure>

BigQuery API

<figure><img src="/files/yukpG6TuJdEXgQWKf4dP" alt=""><figcaption></figcaption></figure>

Eventarc API

<figure><img src="/files/vaz7EDKqAQqgZ1iez6Ut" alt=""><figcaption></figcaption></figure>

## Create Service Account

The Service Account gives access to Stacksync to your data for it to be synced. It is used to set up all the necessary Stacksync Services in your Google Cloud Project. You will need to create one Service Account dedicated to Stacksync which will enable you with better access control.

#### 1. Open <https://console.cloud.google.com/iam-admin/serviceaccounts>

#### 2. Click "Create Service Account"

<figure><img src="/files/Ty5r7Cr3Z7uqGn7WUqG3" alt=""><figcaption></figcaption></figure>

#### 3. Fill in the Service Account details

<figure><img src="/files/IFjsEJV7DyMDLF7FRpuQ" alt=""><figcaption></figcaption></figure>

#### 4. Click "Select a role"

<figure><img src="/files/xdia99GHJ5aAqKGwBLDT" alt=""><figcaption></figcaption></figure>

#### 5. Add the following Roles to the Service Account

These roles are necessary for Stacksync to get data access and set up the required services to make the data sync happen.

1. BigQuery Data Editor
2. BigQuery Job User
3. Cloud Functions Service Agent
4. Cloud Run Developer
5. Eventarc Event Receiver
6. Eventarc Service Agent

<figure><img src="/files/OANvdZdMG1MT8HocF8cE" alt=""><figcaption></figcaption></figure>

#### 6. Click "Continue"

<figure><img src="/files/nAIPBPlTQKGm9EbHrgEC" alt=""><figcaption></figcaption></figure>

#### 7. Click "DONE"

<figure><img src="/files/Ry44a60Xv5muNhwxXoEW" alt=""><figcaption></figcaption></figure>

## Adding Credentials to Stacksync

#### 1. Go to <https://console.cloud.google.com/iam-admin/serviceaccounts>

#### 2. Click "Keys"

<figure><img src="/files/LyKge1ThC5q7U6oHiVam" alt=""><figcaption></figcaption></figure>

#### 3. Click "Add Key" and Select "Create New Key"

<figure><img src="/files/SGKF9SzVvVCVmjg34ztB" alt=""><figcaption></figcaption></figure>

#### 4. Select Key Type "JSON" and click "Create"

After clicking "Create", the JSON file will be downloaded.

<figure><img src="/files/bAtPtjEOWMNSpRWVqclt" alt=""><figcaption></figcaption></figure>

#### 5. Select BigQuery in the Create Base page in Stacksync

<figure><img src="/files/rICHEl5xY9o4Kpe1HxAQ" alt=""><figcaption></figcaption></figure>

#### 6. Upload the JSON file from Step 4 and Click "Authorize App"

<figure><img src="/files/N833KEOurzneE5jEXW2M" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stacksync.com/two-way-sync/connectors/bigquery/authorize-bigquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
