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

# Connect

> Connect with the Linked Account's Snowflake account.

<Note>
  Snowflake is an **API Key** based integration and does not require the setup of an app.
</Note>

### Required Credentials of a Linked Account

To successfully connect with the **Snowflake** integration, a Linked Account or an end-user will need to provide the following to connect:

1. Private Key
2. Passphrase
3. Username
4. Account Identifier

<Info>
  To understand how a Linked Account can get the above mentioned credentials, refer below.
</Info>

### Getting Credentials of Snowflake

To acquire the required credentials and connect a Linked Account, please follow the steps mentioned below:

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_config.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=d9afce7caa9b854304b18aebd213fa05" alt="Connect a Linked Account" data-path="images/Snowflake/snowflake_config.png" />

1. Log in to your [Snowflake account](https://app.snowflake.com/), click on your profile in the bottom left and under `Account` click on `Copy Account Identifier`. This is your Account Identifier which you need for authentication.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_id.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=7c6e34c2b450fede1d539f63a0ea0d04" alt="Get Account Identifier" data-path="images/Snowflake/snowflake_id.png" />

2. Click on the `My Profile` option in the bottom left and copy the `Username` given.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_username.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=10d2a794d4741ab0d649b63142bec19f" alt="Snowflake Username" data-path="images/Snowflake/snowflake_username.png" />

3. Open **Terminal/Bash** in your laptop(Linux/Mac/Windows) and type the following command:

```bash Command theme={null}
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out private_key.p8 -scrypt
```

4. You will be prompted to provide `Encryption Password`. Provide a password, verify it and save it with you. This is your `Passphrase` for authentication.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_pass.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=b2971c36b42e423d5132a5822a2bb37c" alt="Snowflake Passphrase" data-path="images/Snowflake/snowflake_pass.png" />

This Generates a file called `private_key.p8` in the current directory.

5. Open your `private_key.p8` file in the terminal by using the following command and save it. This is your `Private Key`.

```base Command theme={null}
cat private_key.p8
```

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_private.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=86bf8cd79b2f5052433c5396e7cbd57e" alt="Getting Private Key" data-path="images/Snowflake/snowflake_private.png" />

6. Generate `Public Key` using your passphrase from the 4th step by using the following command:

```bash Command theme={null}
 openssl rsa -in private_key.p8 -pubout -out public_key.pem -passin pass:<your_passphrase>
```

7. Open your `public_key.pem` file that was generated in last step using the command:

```base Command theme={null}
cat public_key.pem 
```

Copy the **Public Key** displayed in your terminal.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_public.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=674b7bcfcc39dea5b24e99471e889a7d" alt="Getting Public Key" data-path="images/Snowflake/snowflake_public.png" />

8. Go to Snowflake and click on your profile in the bottom left. Check if your current role is `ACCOUNTADMIN` or not under **Switch Role**. If not, switch role to ACCOUNTADMIN.

<Info>
  ACCOUNTADMIN Role is necessary, otherwise you won't be able to assign public key to user in the next step.
</Info>

9. In Snowflake click on `Worksheets` under **Projects** in the side menu. Click on `+` icon to create a new worksheet.
10. Run the following statement in your worksheet by replacing the **Username** and **Public\_key** with your own credentials.

```base Statement theme={null}
ALTER USER <Username> SET RSA_PUBLIC_KEY="<Public_key>"
```

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Snowflake/snowflake_assign.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=535d72d6eab1cc7b8b169ed7fada397e" alt="Assigning Public Key to user" data-path="images/Snowflake/snowflake_assign.png" />

The Linked Account or end-user now have all the credentials required to connect with Snowflake.

#### Actions and triggers

In Refold, you can create orchestrations of your use-cases using Snowflake actions and triggers. Following are the set of Snowflake actions and triggers
supported by Refold.

<Tabs>
  <Tab title="Actions">
    <AccordionGroup>
      <Accordion title="Statements">
        1. **Create Statement** - Create a SQL statement in Snowflake.
        2. **Get Statement** - Retrieve the result of a SQL statement execution in Snowflake.
        3. **Cancel Statement** - Cancel an ongoing SQL statement in Snowflake.
      </Accordion>

      <Accordion title="Others">
        4. **HTTP Request** - Make HTTP API calls to any Snowflake documented REST APIs.
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Triggers">
    There are no triggers in this application.
  </Tab>
</Tabs>
