# Snowflake

## Configuration

### Prerequisites

If your database is hosted behind a Firewall, you need to add our [IP addresses](https://docs.uibakery.io/concepts/data-sources#whitelisting-ip-addresses) to the Firewall whitelist.

### Connecting the data source

1. On the **Data sources** page, click **Connect**, and select *Snowflake* in the Data sources list.
2. In connection settings, specify all the necessary credentials.

{% hint style="warning" %}
Make sure to specify the **Role** that has access to the required resource.
{% endhint %}

4. Select the preferred *authentication setting*:

* [**OAuth**](#snowflake-oauth-configuration) - each user will be asked to authenticate Snowflake via OAuth flow to obtain a personal token.&#x20;
* **Key-pair** - enhanced authentication security method which requires, as a minimum, a 2048-bit RSA key pair. \
  To configure key-pair authentication, check out [Snowflake documentation](https://docs.snowflake.com/en/user-guide/key-pair-auth).
* **Password** - all requests to Snowflake are made with the username/password entered during creation.

{% hint style="danger" %}
Be aware that Snowflake is planning to [block sign-ins using single-factor authentication with password](https://www.snowflake.com/en/blog/blocking-single-factor-password-authentification/) by November 2025.
{% endhint %}

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2Fg294I5JUVoHYdjYHTnMc%2FCleanShot%202025-04-03%20at%2012.39.22%402x-min.png?alt=media&#x26;token=413581b4-7057-48a5-8560-cb31ee9f4e5b" alt=""><figcaption></figcaption></figure>

5. (Optional) If you need to be able to override the default data source database with a custom value in an action, you can enable the **Allow override database name in action** setting.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FxOazFwkPGhz46SYasRYy%2FCleanShot%202025-04-03%20at%2014.41.04%402x-min.png?alt=media&#x26;token=7912212e-6bb8-4a60-b967-51d00968e4cb" alt=""><figcaption></figcaption></figure>

Once enabled, when configuring the action, you will be able to specify the custom database. In case a database is not specified, the default data source database will be used.

6. Click **Test connection** to verify whether the connection can be established and then proceed to **Connect Datasource.**

#### Snowflake OAuth configuration

[Snowflake OAuth](https://docs.snowflake.com/en/user-guide/oauth-custom.html) supports role-based access and audit user requests made from the UI Bakery application.

{% hint style="info" %}
In the case of OAuth connection setup, data source credentials will not be shared among UI Bakery users. Each user will be prompted to additionally authenticate themselves with Snowflake during the first usage of the app or when their token expires.
{% endhint %}

**To configure Snowflake OAuth, follow the steps below:**

1. Create a security integration. \
   Replace **UI\_BAKERY\_REDIRECT\_URL** with the value from the UI Bakery Snowflake configuration screen.

```sql
CREATE SECURITY INTEGRATION UIBAKERY
TYPE = OAUTH
ENABLED = TRUE
OAUTH_CLIENT = CUSTOM
OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
OAUTH_REDIRECT_URI = 'UI_BAKERY_REDIRECT_URL'
```

2\. Find **Client ID** and **Client** **secret** of the security integration.

```sql
  SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('UIBAKERY');
```

3. Paste these values to the corresponding fields in the connection settings and click **Connect to snowflake**.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FLjkeZvFwXftxQf0HAj2S%2FCleanShot%202025-04-03%20at%2012.55.09%402x-min.png?alt=media&#x26;token=f7a484db-52f0-4e98-ad91-53ac7f5ad697" alt=""><figcaption></figcaption></figure>

4. Finally, click **Connect Datasource**.

When users make a request to the datasource for the first time, they will be prompted to authenticate themselves with Snowflake.

{% hint style="info" %}
Updating datasource connection setting will revoke all user tokens, so users will be asked to authenticate again.
{% endhint %}

## Usage

Once you've established the connection between UI Bakery and Snowflake, you can start interacting with its data. For this purpose, you can use the [SQL Query ](https://docs.uibakery.io/reference/working-with-actions/sql-query)action step:

1. Add a new action, select your data source, and select **SQL Query** from the actions list.

{% hint style="danger" %}
Note that pre-defined actions, such as *Load Table*, *Create Row*, etc. are NOT supported with this data source.
{% endhint %}

2. Next, specify your query and click **Execute action** to launch it.
3. Check the **Result** tab to make sure your data is loaded.


---

# 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.uibakery.io/reference/data-sources/snowflake.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.
