Skip to main content

Connect Snowflake to Triple Whale with a programmatic access token (PAT)

Set up your Snowflake integration using a dedicated role, integration user, and a programmatic access token (PAT).

K
Written by Kassandra Villa Arroyo

Overview

This guide walks you through connecting Triple Whale to your Snowflake account using a programmatic access token (PAT). You first run a set of SQL commands in Snowflake to create a dedicated role, a dedicated integration user, an authentication policy, and the token. You then enter the token and connection details in Triple Whale. Once connected, you can use Snowflake as a destination in Workflows.

1. PAT Token Generation

To generate the PAT Token you need to run the following commands.

These will generate the prerequisites and the PAT Token

  1. Create a Dedicated Role

CREATE ROLE IF NOT EXISTS TW_INTEGRATION_ROLE; -- Warehouse access (required to run queries) 
GRANT USAGE ON WAREHOUSE <WAREHOUSE_NAME> TO ROLE TW_INTEGRATION_ROLE;
-- Database & Schema access
GRANT USAGE ON DATABASE <DB_NAME> TO ROLE TW_INTEGRATION_ROLE;
GRANT USAGE ON SCHEMA <DB_NAME>.<SCHEMA_NAME> TO ROLE TW_INTEGRATION_ROLE;
-- Allow table creation (if needed)
GRANT CREATE TABLE ON SCHEMA <DB_NAME>.<SCHEMA_NAME> TO ROLE TW_INTEGRATION_ROLE;
-- Insert permissions
GRANT INSERT ON ALL TABLES IN SCHEMA <DB_NAME>.<SCHEMA_NAME> TO ROLE TW_INTEGRATION_ROLE;
GRANT INSERT ON FUTURE TABLES IN SCHEMA <DB_NAME>.<SCHEMA_NAME> TO ROLE TW_INTEGRATION_ROLE;

2. Create a Dedicated Integration User

CREATE USER IF NOT EXISTS triplewhale_integration 
DEFAULT_WAREHOUSE = <WAREHOUSE_NAME>;
-- Grant the integration role to the user
GRANT ROLE TW_INTEGRATION_ROLE TO USER triplewhale_integration;
-- Set the role as default (after it has been granted)
ALTER USER triplewhale_integration SET DEFAULT_ROLE = TW_INTEGRATION_ROLE;

3. Create an Authentication Policy for PAT without IP Enforcement

CREATE AUTHENTICATION POLICY IF NOT EXISTS triplewhale_pat_policy AUTHENTICATION_METHODS = ('PROGRAMMATIC_ACCESS_TOKEN') PAT_POLICY = ( NETWORK_POLICY_EVALUATION = NOT_ENFORCED ); 

-- Attach the policy to the integration user
ALTER USER triplewhale_integration
SET AUTHENTICATION POLICY triplewhale_pat_policy;

4. Issue a Programmatic Access Token (PAT – 365 Days)

Important:
Copy the PAT secret that is displayed immediately after running this command. It is shown only once and must be provided to Triple Whale in the integration form.

ALTER USER triplewhale_integration 
ADD PROGRAMMATIC ACCESS TOKEN tw_export_token
DAYS_TO_EXPIRY = 365
COMMENT='Triple Whale export PAT (365 days)';

-- Verify: - (Optional)
SHOW USER PROGRAMMATIC ACCESS TOKENS FOR USER triplewhale_integration; SHOW USERS LIKE 'TRIPLEWHALE_INTEGRATION'; -- HAS_PAT should be TRUE

2.Connect in Triple Whale

  1. In Triple Whale, go to Data > Integrations.

  2. Locate Snowflake and click Connect.

  3. Click the Use alternative connection method link at the bottom of the connection screen and choose the PAT option.

  4. Enter your connection details and paste the PAT secret you copied in step 4 of PAT Token Generation.

  5. Click Save.

Did this answer your question?