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

# Configuring native OAuth for Snowflake databases

> Configure native Snowflake OAuth, allowing each Omni user to authenticate with their Snowflake credentials when running queries.

> [!NOTE]
>
> For authenticating Snowflake users with Okta, see [Snowflake + Okta External OAuth](https://docs.omni.co/connect-data/oauth/snowflake/external-okta.md).

## Requirements

To follow the steps in this guide, you'll need:

* **In Omni**:
  * **Organization Admin** permissions
  * **An existing Snowflake connection.** Refer to [Connecting a Snowflake database](https://docs.omni.co/connect-data/setup/snowflake.md) before continuing.
* **A Snowflake service account with access to all schemas and tables you want to use in Omni**. This is required even when OAuth is enabled, because Omni uses the service account to build the model.

> [!WARNING]
>
> Before continuing, review the [OAuth limitations](https://docs.omni.co/connect-data/oauth#limitations).

## Setup

### 1. Create a Snowflake OAuth integration

Create an OAuth integration in Snowflake using `https://callbacks.omniapp.co/callback/oauth` as the `OAUTH_REDIRECT_URI`, then retrieve the **Client ID** and **Client Secret**. Refer to [Snowflake's OAuth documentation](https://docs.snowflake.com/en/user-guide/oauth-intro) for instructions.

> [!NOTE]
>
> **Vanity-domain embed users**: If you're using OAuth with [vanity-domain embeds](https://docs.omni.co/embed/customization/vanity-domains.md), you'll also need to register your vanity domain's OAuth callback URL. Run the following command in Snowflake to add the vanity callback URL to your existing OAuth integration:
>
> ```sql wrap theme={null}
> ALTER SECURITY INTEGRATION <your-integration-name>
>   SET OAUTH_REDIRECT_URI = 'https://callbacks.omniapp.co/callback/oauth,https://<your-vanity-domain>/callback/oauth';
> ```
>
> Replace `<your-integration-name>` with your integration's name and `<your-vanity-domain>` with your vanity domain (e.g., `omni.myapp.com`).

### 2. Add Omni's IP addresses to your network policy

> [!NOTE]
>
> Skip this step if your Snowflake account doesn't restrict access by IP addresses using a [network policy](https://docs.snowflake.com/en/user-guide/network-policies).

If your Snowflake account restricts access by IP address with a [network policy](https://docs.snowflake.com/en/user-guide/network-policies), you may also need to apply a network policy that allows Omni's IP addresses to the OAuth security integration itself. An account-level network policy isn't always enough, as Snowflake can enforce network policies separately on security integrations. See [Snowflake's documentation on restricting OAuth with network policies](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview#label-snow-oauth-network-policies) for more information.

1. In Omni, navigate to **Settings > Connections** and click the connection. The IP addresses will be listed on this page.
2. In Snowflake, add the IP addresses to a network policy.
3. Set the `NETWORK_POLICY` parameter on the security integration:

   ```sql wrap theme={null}
   ALTER SECURITY INTEGRATION <your-integration-name>
     SET NETWORK_POLICY = '<your-network-policy-name>';
   ```

   Replace `<your-integration-name>` with your integration's name and `<your-network-policy-name>` with the name of a network policy that includes Omni's IP addresses.

### 3. Configure the connection in Omni

> [!NOTE]
>
> You must still configure a service account on this connection. Omni uses the service account to build the model, which provides the foundation for all user queries.

This guide assumes you have an existing Snowflake connection in Omni. If you don't, refer to [Connecting a Snowflake database](https://docs.omni.co/connect-data/setup/snowflake.md) for more information.

1. In Omni, navigate to **Settings > Connections** and click on the Snowflake connection you want to use.
2. Fill in the fields as follows:
   * **Authentication Type** - Select **OAuth User Authentication**
   * **OAuth Client ID** - Enter the **Client ID** from the previous step
   * **OAuth Client Secret** - Enter the **Client secret** from the previous step
   * **Warehouse** - **Optional**: Leave blank to use each user's `DEFAULT_WAREHOUSE` from Snowflake. This enables per-user warehouse routing for organizations using role-to-warehouse mappings in Snowflake for cost attribution.

     **Users must have an assigned default warehouse to use this feature.** Otherwise, users without a default warehouse will receive a `No active warehouse` error when they attempt to run queries in Omni.
3. Save the connection settings.

### 4. Verify the user experience

After saving, each Omni user will be prompted to authenticate with Snowflake the first time they run a query in a workbook or dashboard. This prompt reappears when their OAuth token expires.

Once authenticated, Omni uses the user's database permissions in place of the service account for all queries that user runs.

> [!TIP]
>
> **Running into issues?** See the [Troubleshooting Snowflake OAuth](https://docs.omni.co/connect-data/oauth/snowflake/troubleshooting.md) for help with diagnosing and resolving common Snowflake OAuth problems.

## Next steps

To ensure database permissions align with what users see in Omni, we recommend implementing:

* [**Access grants**](https://docs.omni.co/modeling/models/access-grants.md) to control which fields and tables are visible to each user in the model and field browser
* [**Content permissions**](https://docs.omni.co/administration/users/permissions.md) to control which dashboards and documents users can access
