> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datafold.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OAuth Support

> Set up OAuth App Connections in your supported data warehouses to securely execute data diffs on behalf of your users.

<Note>
  This feature is currently supported for Databricks, Snowflake, Redshift, and BigQuery.
</Note>

OAuth support empowers users to run data diffs based on their individual permissions and roles configured within the data warehouses. This ensures that data access is governed by existing security policies and protocols.

## Overview

The diagram below illustrates how the authentication flow proceeds:

1. Users authenticate using the configured OAuth provider.
2. Users can then create diffs between data sets that their user can access using OAuth database permissions.
3. During Continuous Integration (CI), Datafold executes diffs using a Service Account with the least privileges, thus masking sensitive/PII data.
4. If a user needs to see sensitive/PII data from a CI diff, and they have permission via OAuth to do so, they can rerun the diff, and then Datafold will authenticate the user using OAuth database permissions. Then, the user will have access to the data based on these permissions.

This structure ensures that diffs are executed with the user's database credentials with their configured roles and permissions. Data access permissions are thus fully managed by the database, and Datafold only passes through queries.

<Frame>
  <img src="https://mintcdn.com/datafold/9DgdnO4sVNte36u-/images/rbac-with-sso-auth-flow-f641e578b9ee12f4ab09e5573125cb0a.png?fit=max&auto=format&n=9DgdnO4sVNte36u-&q=85&s=c97a5cc781ff4bd1209c9efe06e5c1c6" width="3898" height="2950" data-path="images/rbac-with-sso-auth-flow-f641e578b9ee12f4ab09e5573125cb0a.png" />
</Frame>

## How it works

### 1. Create a Data Diff

When you attempt to run a data diff, you will notice that it won't run without authentication:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/1-b9afb4d6ec25ca58b9a033ff1eaf6efb.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=cd7e4bebaad25ee87ee8f9af1276b394" width="1351" height="506" data-path="images/1-b9afb4d6ec25ca58b9a033ff1eaf6efb.png" />
</Frame>

### 2. Authorize the Data Diff

Authorize the data diff by clicking the **Authenticate** button. This will redirect you to the data warehouse for authentication:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/2-01bbf79b7aaf007bc33dc4652a825e31.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=ed69e89b64e6a3d78420304cad83aa56" width="692" height="689" data-path="images/2-01bbf79b7aaf007bc33dc4652a825e31.png" />
</Frame>

Upon successful authentication, you will be redirected back.

### 3. The Data Diff is now running

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/3-7d49f847dba2d6ebefe0215a7251d3e7.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=0cd380754dc3b5894e055590d2638473" width="1444" height="660" data-path="images/3-7d49f847dba2d6ebefe0215a7251d3e7.png" />
</Frame>

### 4. View the Data Diff results

The results reflect your permissions within the data warehouse:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/4-1e3cf172b19bd6616700f3c82f17b256.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=897aa005c633ba7fdea578447a97828a" width="616" height="329" data-path="images/4-1e3cf172b19bd6616700f3c82f17b256.png" />
</Frame>

Note that running the same data diff, as a different user, renders different results:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/5-585c0ee49689bb8af229ad44eb260ace.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=5e89ea4ea01811b1ffcdab58f0c7990e" width="668" height="348" data-path="images/5-585c0ee49689bb8af229ad44eb260ace.png" />
</Frame>

The masked values represent the data retrieved from the data warehouse. We do not conduct any post-processing:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/6-f09d99fb5db326846be80a54d24606b0.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=3783c5502d8e301edc487ddb2d7fbef3" width="2019" height="522" data-path="images/6-f09d99fb5db326846be80a54d24606b0.png" />
</Frame>

By default, results are only visible to their authors. Users can still clone data diffs, but the results may differ depending on their data warehouse access levels.

For example, another user would not be able to access the data diff results from the previous example:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/7-0e23da80a3e63960a91301cdf38d8207.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=abbc65d13fd6f9fd766ae84fb815d9b1" width="1253" height="526" data-path="images/7-0e23da80a3e63960a91301cdf38d8207.png" />
</Frame>

### 5. Sharing Data Diffs

Data diff sharing is a feature that enables you to share data diffs with other users. This is useful in scenarios such as compliance verification, where auditors can access specific data diffs without first requiring permissions to be set up in the data warehouse.

Sharing can be accessed via the **Actions** dropdown on the data diff page:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/1-2f00e7c34ec87bada9d464dcb97053df.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=789165034442807be5003399934f40f7" width="379" height="356" data-path="images/1-2f00e7c34ec87bada9d464dcb97053df.png" />
</Frame>

Note that data diff sharing is disabled by default:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/2-badcc3a6ac297bc1c3ff27f8f4b6c9e0.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=ebfb0bfc01a1ced78c489906b41354fc" width="693" height="329" data-path="images/2-badcc3a6ac297bc1c3ff27f8f4b6c9e0.png" />
</Frame>

It can be enabled under **Org Settings** by clicking on **Allow Data Diff sharing**:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/3-889664da5c85c56985659d0c9e675340.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=bc1bf09028d88aa65d3a3ce75508810f" width="1154" height="422" data-path="images/3-889664da5c85c56985659d0c9e675340.png" />
</Frame>

Once enabled, you can share data diffs with other users:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/4-58827ded9574bddc7ef7ce0d4f156bf8.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=12830c2279779e7344273e1b9ce72aab" width="913" height="774" data-path="images/4-58827ded9574bddc7ef7ce0d4f156bf8.png" />
</Frame>

## Configuring OAuth

Navigate to **Settings** and click on your data connection. Then, click on **Advanced settings** and under **OAuth**, set the **Client Id** and **Client Secret** fields:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/1-6541ee9948bb173fe28a64cb72b7ba8d.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=483e82a0cfd9eb259f7423eb1ff97498" width="1639" height="623" data-path="images/1-6541ee9948bb173fe28a64cb72b7ba8d.png" />
</Frame>

## Example: Databricks

To create a new Databricks app connection:

1. Go to **Settings** and **App connections**.
2. Click **Add connection** in the top right of the screen.

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/2-f59b84118a8979128d2476989b4f5262.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=a69989f57df0f8720e00a76f98816b38" width="714" height="835" data-path="images/2-f59b84118a8979128d2476989b4f5262.png" />
</Frame>

3. Fill in the required fields:

Application Name:

```
Datafold OAuth connection
```

Redirect URLs:

```
https://app.datafold.com/api/internal/oauth_dwh/callback
```

<Note>
  Datafold caches **access tokens** and uses **refresh tokens** to fetch new valid tokens in order to complete the diffs and reduce the number of times users need to authenticate against the data warehouses.

  One hour is sufficient for the access token.

  The refresh token will determine the frequency of user reauthentication, whether it's daily, weekly, or monthly.
</Note>

4. Click **Add** to obtain the **Client ID** and **Client Secret**.

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/3-c59900f8bd662e3ee8036f40eb2fcc4d.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=589b0cf2f42d86c1ec263cc47fb33365" width="628" height="391" data-path="images/3-c59900f8bd662e3ee8036f40eb2fcc4d.png" />
</Frame>

5. Fill in the **Client ID** and **Client Secret** fields in Datafold's Data Connection advanced settings:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/4-75640ad5d18710fced1d22c108bbd0c9.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=52b22b3c356fb6b6d7e4a905687d2715" width="1584" height="338" data-path="images/4-75640ad5d18710fced1d22c108bbd0c9.png" />
</Frame>

6. Click **Test and save OAuth**. You will be redirected to Databricks to complete authentication. If you are already authenticated, you will be redirected back. This notification signals a successful OAuth configuration:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/5-63f6c2f97041e030191e9abc5ca70637.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=821eded0675f2c3319efee82e368caed" width="1647" height="1284" data-path="images/5-63f6c2f97041e030191e9abc5ca70637.png" />
</Frame>

### Additional steps for Databricks

To ensure that users have correct access rights to temporary tables (stored in **Dataset for temporary tables** provided in the **Basic settings** for the Databricks connection), follow these steps:

1. Update the permissions for the **Dataset for temporary tables** in Databricks.
2. Grant these permissions to Datafold users: **USE SCHEMA** and **CREATE TABLE**.

This will ensure that materialization results from data diffs are only readable by their authors.

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/6-c4186dd5e91cd8aabf283649efe7461e.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=6a231a976529a7d6fbfdfa11e9638197" width="1138" height="1239" data-path="images/6-c4186dd5e91cd8aabf283649efe7461e.png" />
</Frame>

## Example: Snowflake

To create a new Snowflake app connection:

1. Go to Snowflake and run this SQL:

```sql theme={null}
CREATE SECURITY INTEGRATION DATAFOLD_OAUTH
TYPE = OAUTH
ENABLED = TRUE
OAUTH_CLIENT = CUSTOM
OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
OAUTH_REDIRECT_URI = 'https://app.datafold.com/api/internal/oauth_dwh/callback'
PRE_AUTHORIZED_ROLES_LIST=(<ROLENAME1>, <ROLENAME2>, ...)
OAUTH_ISSUE_REFRESH_TOKENS = TRUE
OAUTH_REFRESH_TOKEN_VALIDITY = 604800
OAUTH_ENFORCE_PKCE=TRUE;
```

<Warning>
  **CAUTION**

  * `PRE_AUTHORIZED_ROLES_LIST` must include all roles allowed to use the current security integration.
  * By default, `ACCOUNTADMIN`, `SECURITYADMIN`, and `ORGADMIN` are not allowed to be included in `PRE_AUTHORIZED_ROLES_LIST`.
</Warning>

<Note>
  Datafold caches **access tokens** and uses **refresh tokens** to fetch new valid tokens in order to complete the diffs and reduce the number of times users need to authenticate against the data warehouses.

  `OAUTH_REFRESH_TOKEN_VALIDITY` can be in the range of 3600 (1 hour) to 7776000 (90 days).
</Note>

2. To retrieve `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET`, run the following SQL:

```sql theme={null}
select system$show_oauth_client_secrets('DATAFOLD_OAUTH');
```

Example result:

<Frame>
  <img src="https://mintcdn.com/datafold/BHI8Zy_v4DyXlmzL/images/oauth_snowflake_client_creds-47b11899ea2d5df0fce5f17f1711dc62.png?fit=max&auto=format&n=BHI8Zy_v4DyXlmzL&q=85&s=ce9a57e787e1d1a98b9cb10bc77cc2be" width="1471" height="71" data-path="images/oauth_snowflake_client_creds-47b11899ea2d5df0fce5f17f1711dc62.png" />
</Frame>

3. Fill in the **Client ID** and **Client Secret** fields in Datafold's Data Connection advanced settings:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/4-75640ad5d18710fced1d22c108bbd0c9.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=52b22b3c356fb6b6d7e4a905687d2715" width="1584" height="338" data-path="images/4-75640ad5d18710fced1d22c108bbd0c9.png" />
</Frame>

4. Click **Test and save OAuth**. You will be redirected to Snowflake to complete authentication.

<Note>
  Your default Snowflake role will be used for the generated **access token**.
</Note>

This notification signals a successful OAuth configuration:

<Frame>
  <img src="https://mintcdn.com/datafold/7pWtpSckJi2T0xZR/images/5-63f6c2f97041e030191e9abc5ca70637.png?fit=max&auto=format&n=7pWtpSckJi2T0xZR&q=85&s=821eded0675f2c3319efee82e368caed" width="1647" height="1284" data-path="images/5-63f6c2f97041e030191e9abc5ca70637.png" />
</Frame>

### Additional steps for Snowflake

To guarantee correct access rights to temporary tables (stored in **Schema for temporary tables** provided in the **Basic settings** for Snowflake connection):

* Grant the required privileges on the database and `TEMP` schema for all roles that will be using the OAuth flow.

```sql theme={null}
GRANT USAGE ON WAREHOUSE <WH_NAME> TO ROLE <ROLENAME>;
GRANT USAGE ON DATABASE <DB_NAME> TO ROLE <ROLENAME>;
GRANT USAGE ON ALL SCHEMAS IN DATABASE <DB_NAME> TO ROLE <ROLENAME>;
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE <DB_NAME> TO ROLE <ROLENAME>;
GRANT ALL ON SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> TO ROLE <ROLENAME>;
```

* Revoke `SELECT` privileges for tables in the `TEMP` schema for all roles that will be using the OAuth flow (except for the `DATAFOLDROLE` role), if they were provided. This action must be performed for all roles utilizing the OAuth flow.

```sql theme={null}
-- Revoke SELECT privileges for the TEMP SCHEMA
revoke SELECT ON ALL TABLES IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE TABLES IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON ALL VIEWS IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE VIEWS IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON ALL MATERIALIZED VIEWS IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE MATERIALIZED VIEWS IN SCHEMA <DB_NAME>.<TEMP_SCHEMA_NAME> FROM ROLE <ROLENAME>;
-- Revoke SELECT privileges for a Database
revoke SELECT ON ALL TABLES IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE TABLES IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON ALL VIEWS IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE VIEWS IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON ALL MATERIALIZED VIEWS IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
revoke SELECT ON FUTURE MATERIALIZED VIEWS IN DATABASE <DB_NAME> FROM ROLE <ROLENAME>;
```

<Warning>
  **CAUTION**

  If one of the roles has `FUTURE GRANTS` at the database level, this role will also have `FUTURE GRANTS` on the `TEMP` schema.
</Warning>

## Example: Redshift

Redshift does not support OAuth2. To execute data diffs on behalf of a specific user, that user needs to provide their own credentials to Redshift.

1. Configure permissions on the Redshift side. Grant the necessary access rights to temporary tables (stored in the **Schema for temporary tables** provided in the **Basic settings** for Redshift connection):

```sql theme={null}
GRANT USAGE on SCHEMA <TEMP_SCHEMA_NAME> to <USERNAME>;
GRANT CREATE on SCHEMA <TEMP_SCHEMA_NAME> to <USERNAME>;
```

2. As an Administrator, select the **Enabled** toggle in Datafold's Redshift Data Connection **Advanced settings**:

<Frame>
  <img src="https://mintcdn.com/datafold/9DgdnO4sVNte36u-/images/redshift_enable_toggle-df94b6b675d5b7a080b0569fed4943b0.png?fit=max&auto=format&n=9DgdnO4sVNte36u-&q=85&s=1225a8001fa74dbeeead41b1675b2af1" width="573" height="357" data-path="images/redshift_enable_toggle-df94b6b675d5b7a080b0569fed4943b0.png" />
</Frame>

Then, click the **Test and Save** button.

3. As a User, add your Redshift credentials into Datafold. Click on your Datafold username to **Edit Profile**:

<Frame>
  <img src="https://mintcdn.com/datafold/9DgdnO4sVNte36u-/images/redshift_credentials_ui-749a49c20ca40f8857831a49526473cc.png?fit=max&auto=format&n=9DgdnO4sVNte36u-&q=85&s=94bb0a38ce1502c37884fbfdcce735b4" width="428" height="276" data-path="images/redshift_credentials_ui-749a49c20ca40f8857831a49526473cc.png" />
</Frame>

Then, click **Add credentials** and select the required Redshift data connection from the **Data Connections** list:

<Frame>
  <img src="https://mintcdn.com/datafold/9DgdnO4sVNte36u-/images/redshift_before_create_creds-09bad0b040c673230f8890d35e883533.png?fit=max&auto=format&n=9DgdnO4sVNte36u-&q=85&s=4bd6e92d2df678a8625f8b69be7c4580" width="533" height="365" data-path="images/redshift_before_create_creds-09bad0b040c673230f8890d35e883533.png" />
</Frame>

Finally, provide your Redshift username and password, and configure the **Delete on** field (after this date, your credentials will be removed from Datafold):

<Frame>
  <img src="https://mintcdn.com/datafold/9DgdnO4sVNte36u-/images/redshift_create_creds-efc65762308b064bfd208a0b3f19c4b3.png?fit=max&auto=format&n=9DgdnO4sVNte36u-&q=85&s=d3f72a0e9d5dabfb88870f81f1e7bdfc" width="531" height="475" data-path="images/redshift_create_creds-efc65762308b064bfd208a0b3f19c4b3.png" />
</Frame>

Click **Create credentials**.

## Example: BigQuery

1. Create a new Google Cloud OAuth 2.0 Client ID. Go to the Google Cloud console, navigate to **APIs & Services**, then **Credentials**, and click **+ CREATE CREDENTIALS**:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_create_btn-15e16ea9d19edb6d0ad61835bd774970.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=4905913a31f2f328e7a755ac5d09650d" width="1034" height="304" data-path="images/gcloud_create_btn-15e16ea9d19edb6d0ad61835bd774970.png" />
</Frame>

Select **OAuth client ID**:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_create_type-6412ecce9428e3aaf21722c81daa0ac9.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=0e709d4a6a5916bf21c6f940553c2a9c" width="502" height="275" data-path="images/gcloud_create_type-6412ecce9428e3aaf21722c81daa0ac9.png" />
</Frame>

From the list of **Application type**, select **Web application**:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_select_type-a21194f9850db4fe9d6babea49a36ba9.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=c197423a208dc2d144b9dcd2cbc905a9" width="617" height="459" data-path="images/gcloud_select_type-a21194f9850db4fe9d6babea49a36ba9.png" />
</Frame>

Provide a name in the **Name** field:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_oauth_name-b31b7e54a61b764134fd8f8bab61ccda.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=d35dc1be31c0bc487576675f6e6d07ea" width="605" height="335" data-path="images/gcloud_oauth_name-b31b7e54a61b764134fd8f8bab61ccda.png" />
</Frame>

In **Authorized redirect URIs**, provide `https://app.datafold.com/api/internal/oauth_dwh/callback`:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_redirect_uri-81f4b0fd9d93db76bf043170c6b027d6.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=6a5dee352c37fa168fa413932070893e" width="606" height="391" data-path="images/gcloud_redirect_uri-81f4b0fd9d93db76bf043170c6b027d6.png" />
</Frame>

Click **CREATE**. Then, download the OAuth Client credentials as a JSON file:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_download_json1-1dfd1d02cbe9a84bd1124f24b28a293b.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=1d5f2345d0c3b8dae42fd05ff31010a7" width="959" height="157" data-path="images/gcloud_download_json1-1dfd1d02cbe9a84bd1124f24b28a293b.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_download_json2-c6002a086c551afe7f06615bd1189ad9.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=dce5fb185e1daeccad692b9e2de95ce5" width="570" height="464" data-path="images/gcloud_download_json2-c6002a086c551afe7f06615bd1189ad9.png" />
</Frame>

2. Activate BigQuery OAuth in Datafold by uploading the JSON OAuth credentials in the **JSON OAuth keys file** section, in Datafold's BigQuery Data Connection **Advanced settings**:

<Frame>
  <img src="https://mintcdn.com/datafold/6zQ11m2yiOVjYXTT/images/gcloud_upload_json-72298dc179c0244871824afa1c0d1362.png?fit=max&auto=format&n=6zQ11m2yiOVjYXTT&q=85&s=ec7651764c65ca5944a9fba3ecc7abff" width="565" height="364" data-path="images/gcloud_upload_json-72298dc179c0244871824afa1c0d1362.png" />
</Frame>

Click **Test and Save**.

### Additional steps for BigQuery

1. Create a new temporary schema (dataset) for each OAuth user.

Go to Google Cloud console, navigate to BigQuery, select your project in BigQuery, and click on **Create dataset**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_create_dataset1-56868087d2d2829fcf35c92046361179.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=d96e1d0baa2f541b8982e561ccd7dec0" width="854" height="461" data-path="images/bq_create_dataset1-56868087d2d2829fcf35c92046361179.png" />
</Frame>

Provide `datafold_tmp_<username>` as the **Dataset ID** and set the same region as configured for other datasets. Click **CREATE DATASET**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_create_dataset2-ae5cb54f7dfb02699c0a8c6baf991205.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=6f5eee9e23b5e0cc17ac5cf4cf3bbfea" width="600" height="717" data-path="images/bq_create_dataset2-ae5cb54f7dfb02699c0a8c6baf991205.png" />
</Frame>

2. Configure permissions for `datafold_tmp_<username>`.

Grant read/write/create/delete permissions to the user for their `datafold_tmp_<username>` schema. This can be done by granting roles like **BigQuery Data Editor** or **BigQuery Data Owner** or any custom roles with the required permissions.

Go to Google Cloud console, navigate to BigQuery, select `datafold_tmp_<username>` dataset, and click **Manage Permissions**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_config_schema_permissions1-c085ec5f619915d10c8e1819aa31420c.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=9989c77e33d9c8d40101e5aac7c2a979" width="739" height="361" data-path="images/bq_config_schema_permissions1-c085ec5f619915d10c8e1819aa31420c.png" />
</Frame>

Click **+ ADD PRINCIPAL**, specify the user and role, then click **SAVE**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_config_schema_permissions2-2cea1df20480853fe7f9aacf1e786280.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=a3e60b12eaa6d54d9e221013bed04a21" width="604" height="732" data-path="images/bq_config_schema_permissions2-2cea1df20480853fe7f9aacf1e786280.png" />
</Frame>

<Warning>
  Ensure that only the specified user (excluding admins) has read/write/create/delete permissions on `datafold_tmp_<username>`.
</Warning>

3. Configure temporary schema in Datafold.

As a user, navigate to `https://app.datafold.com/users/me`. If the user lacks credentials for BigQuery, click on **+ Add credentials**, select BigQuery datasource from the list, and click **Create credentials**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_datafold_temp_schema1-0ed07791aae93db489b72f56d9a8b956.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=e2622cd1e1be8568cfc8c3c2de089d8f" width="528" height="308" data-path="images/bq_datafold_temp_schema1-0ed07791aae93db489b72f56d9a8b956.png" />
</Frame>

The user will be redirected to `accounts.google.com` and then returned to the previous page:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_datafold_temp_schema2-dc4418e6faa3aaceb9ecccd773618fd4.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=ec94dfc0f8a0cad000a4e5ed291d278d" width="945" height="568" data-path="images/bq_datafold_temp_schema2-dc4418e6faa3aaceb9ecccd773618fd4.png" />
</Frame>

Select BigQuery credentials from the list, input the **Temporary Schema** field in the format `<project>.<datafold_tmp_<username>>`, and click **Update**:

<Frame>
  <img src="https://mintcdn.com/datafold/hQ4DukKOuaj6vjhH/images/bq_datafold_temp_schema3-19e078cdc1acee794bfb92a2abb907a4.png?fit=max&auto=format&n=hQ4DukKOuaj6vjhH&q=85&s=8ec2d70ffeee17a7318a66784aca373a" width="526" height="365" data-path="images/bq_datafold_temp_schema3-19e078cdc1acee794bfb92a2abb907a4.png" />
</Frame>

<Note>
  Users can update BigQuery credentials only if they have the correct permissions for `<datafold_tmp_<username>`.
</Note>
