# Snowflake

## Setup Snowflake Custom OAuth

Details about [custom OAuth for Snowflake](https://docs.snowflake.com/en/user-guide/oauth-custom.html) are described here.

### 1. Create a security integration

First, create a new Worksheet to be able to execute queries. Next, run the below query:

```sql
create security integration oauth_locoia
  type = oauth
  enabled = true
  oauth_client = custom
  oauth_client_type = 'CONFIDENTIAL'
  oauth_redirect_uri = 'https://api.locoia.com/v1/oauth2/callback/snowflake'
  oauth_issue_refresh_tokens = true
  oauth_refresh_token_validity = 86400
 ;
```

Further configuration options can be specified for the security integration if needed.

{% hint style="warning" %}
Only Snowflake account administrators (`ACCOUNTADMIN` role) or a role with the global `CREATE INTEGRATION` privilege can execute this SQL command.
{% endhint %}

### 2. Get the security integration's details

Run the below command to get all Oauth2 details:

```sql
desc security integration oauth_locoia;
```

`oauth_locoia` is the integration name. The result looks like:

![](/files/VVmp937vxDf6gLk0Y6qi)

### 3. Generate the client\_secret

Run the below command:

```sql
select SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('OAUTH_LOCOIA');
```

{% hint style="warning" %}
The integration name needs to be in **upper case** letters.
{% endhint %}

The client\_secret is be returned.

## Authenticating Snowflake

1. In Locoia, go to Settings > Connector Auth and click create. Alternatively create an authentication directly in the [Flow Builder](/automation/flow-builder.md)
2. Enter your details as explained in the images below:

![Names and locator as seen in Snowflake (minimum role to see accounts: ACCOUNTADMIN)](/files/Nd6vKG8LedB3s9YyChEk)

![Entering the corresponding values in the Connector Auth](/files/z3t8hQUbXAjROenG3q6L)

3\. Sign in with your Snowflake credentials. Note that this user can't have the roles `ACCOUNTADMIN`or `SECURITYADMIN`.

![Login with your Snowflake user](/files/tzC2cT6FakFSlhATJTvZ)

4\. In the final step, you need to click **Allow** in order to grant access to the mentioned Snowflake entities:

![](/files/I4f6dYu2qhG49Il559o2)

## API requests to Snowflake

The [Snowflake API](https://docs.snowflake.com/en/developer-guide/sql-api/reference.html#post-api-statements) and its requests is described here.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.locoia.com/connectors/connectors/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.
