TDV Adapter for Snowflake

Build 22.0.8509

Basic Tab

Connecting to Snowflake

In addition to providing authentication (see below) set the following properties to connect to a Snowflake database:

  • Url: Both AWS and Azure instances are supported. For example:
    • AWS: https://myaccount.region.snowflakecomputing.com
    • Azure: https://myaccount.region.azure.snowflakecomputing.com

Account is only required if your Url does not conform to the usual syntax containing the account name at the beginning. Snowflake provides the Account name needed in this case.

Optionally, you can set Database and Schema to restrict the tables and views returned by the adapter.

GCP Instances

To establish a connection to GCP instances, specify this URL:
URL: https://myaccount.gcp.snowflakecomputing.com
The following is an example connection string for working with GCP instances:
jdbc:snowflake:AuthScheme=Basic;url=https://myaccount.gcp.snowflakecomputing.com;user=Admin;password=test123;Database=Northwind;Warehouse=TestWarehouse;Account=Tester1;

Authenticating to Snowflake

The adapter supports Snowflake user authentication, federated authentication, and SSL client authentication. To authenticate, set User and Password, and select the authentication method in the AuthScheme property.

Passwords

Set User and Password to a Snowflake user and set AuthScheme to PASSWORD.

Key Pairs

The adapter allows you to authenticate using key pair authentication by creating a secure token with the private key defined for your user account. To connect with this method, set AuthScheme to PRIVATEKEY and set the following values:

  • User: The user account to authenticate as.
  • PrivateKey: The private key used for the user such as the path to the .pem file containing the private key.
  • PrivateKeyType: The type of key store containing the private key such as PEMKEY_FILE, PFXFILE, etc.
  • PrivateKeyPassword: The password for the specified private key.

Okta

Set the AuthScheme to Okta. The following connection properties are used to connect to Okta:

  • User: Set this to the Okta user.
  • Password: Set this to Okta password for the user.
  • MFAPasscode (optional): Set this to the OTP code that was sent to your device. This property should be used only when the MFA is required for OKTA sign on.
The following SSOProperties are needed to authenticate to Okta:
  • Domain: Set this to the OKTA org domain name.
  • MFAType (optional): Set this to the multi-factor type. This property should be used only when the MFA is required for OKTA sign on. This property accepts one of the following values:
    • OKTAVerify
    • Email
    • SMS
  • APIToken (optional): Set this to the API Token that the customer created from the Okta org. It should be used when authenticating a user via a trusted application or proxy that overrides OKTA client request context. In most contexts, it is not needed.

The following is an example connection string:

AuthScheme=OKTA;User=username;Password=password;Url='https://myaccount.region.snowflakecomputing.com';Warehouse=My_warehouse;SSO Properties='Domain=https://cdata-okta.okta.com';

The following is an example connection string for OKTA MFA:

AuthScheme=OKTA;User=username;Password=password;MFAPasscode=8111461;Url='https://myaccount.region.snowflakecomputing.com';Warehouse=My_warehouse;SSO Properties='Domain=https://cdata-okta.okta.com;MFAType=OktaVerify;';

AzureAD

Set the AuthScheme to AzureAD. The following connection properties are used to connect to AzureAD:
  • User: Set this to your AD user. When connecting, your browser will open allowing you to login to Azure AD to complete the authentication.
The following is an example connection string for AzureAD:
AuthScheme=AzureAD;Url=https://myaccount.region.snowflakecomputing.com;User=user@domain.onmicrosoft.com;

PingFederate

Set the AuthScheme to PingFederate. The following connection properties are used to connect to PingFederate:
  • User: Set this to your PingFederate user, the user should been added to PingFederate Data Stores. When connecting, your browser will open allowing you to login to PingFederate to complete the authentication.
The following is an example connection string for PingFederate(Assuming that Active Directory is used as a Data Store):
AuthScheme=PingFederate;Url=https://myaccount.region.snowflakecomputing.com;User=myuser@mydomain;Account=myaccount;Warehouse=mywarehouse;

OAuth

To authenticate with OAuth, set the AuthScheme to OAuth. You can authenticate by Creating a Custom OAuth App to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties.

Desktop Apps

This section describes desktop authentication using the credentials for your custom OAuth app. See Creating a Custom OAuth App for more information.

Get an OAuth Access Token

After setting the following, you are ready to connect:

  • OAuthClientId: Set to the Client ID in your OAuth Integration settings.
  • OAuthClientSecret: Set to the Client Secret in OAuth your Integration settings.
  • CallbackURL: Set to the Redirect URL in your OAuth Integration settings.
  • InitiateOAuth: Set to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
When you connect, the adapter opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The adapter then completes the following OAuth process:
  1. Extracts the access token from the callback URL and authenticates requests.
  2. Obtains a new access token when the old one expires.
  3. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.

Manually Get an OAuth Access Token

Set the following connection properties to obtain the OAuthAccessToken:

  • InitiateOAuth: Set to OFF.
  • OAuthClientId: Set to the Client ID in your OAuth Integration settings.
  • OAuthClientSecret: Set to the Client Secret in your OAuth Integration settings.

You can then call stored procedures to complete the OAuth exchange:

  1. Call the GetOAuthAuthorizationUrl stored procedure. Set the CallbackURL input to the Redirect URI you specified in your app settings.The stored procedure returns the URL to the OAuth endpoint and the PKCEVerifier.
  2. Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
  3. Call the GetOAuthAccessToken stored procedure. Set the CallbackURL input to the Redirect URI you specified in your app settings. Set the PKCEVerifier input to the value of the PKCEVerifier retrieved form the first step.

Headless Machines

To configure the driver to use OAuth with a user account on a headless machine, you need to authenticate on another device that has an internet browser.

  1. Choose one of these two options:

    • Option 1: Obtain the OAuthVerifier value as described in "Obtain and Exchange a Verifier Code" below.
    • Option 2: Install the adapter on another machine and transfer the OAuth authentication values after you authenticate through the usual browser-based flow, as described in "Transfer OAuth Settings" below.

  2. Then configure the adapter to automatically refresh the access token from the headless machine.

Option 1: Obtain and Exchange a Verifier Code

To obtain a verifier code, you must authenticate at the OAuth authorization URL.

See Creating a Custom OAuth App for a procedure. This section describes the procedure to authenticate and connect to data.

To obtain the verifier code, set the following properties on the headless machine:

  • InitiateOAuth: Set to OFF.
  • OAuthClientId: Set to the Client ID in your OAuth Integration settings.
  • OAuthClientSecret: Set to the Client Secret in your OAuth Integration settings settings.

Next, authenticate from another machine and obtain the OAuthVerifier connection property:

  1. Call the GetOAuthAuthorizationUrl stored procedure. Set the CallbackURL input to the Redirect URI you specified in your app settings.The stored procedure returns the URL to the OAuth endpoint and the PKCEVerifier.
  2. Open the returned URL in a browser. Log in and grant permissions to the adapter. You are then redirected to the callback URL, which contains the verifier code.
  3. Save the value of the Verifier and the value of the PKCEVerifier. You need to set the value of the Verifier in the OAuthVerifier connection property and set the value of the PKCEVerifier in the PKCEVerifier connection property.

Finally, on the headless machine, set the following connection properties to obtain the OAuth authentication values:

  • OAuthClientId: Set to the Client ID in your OAuth Integration settings.
  • OAuthClientSecret: Set to the Client Secret in your OAuth Integration settings.
  • OAuthVerifier: Set to the verifier code.
  • PKCEVerifier: Set to the PKCE verifier code.
  • OAuthSettingsLocation: Set to persist the encrypted OAuth authentication values to the specified file.
  • InitiateOAuth: Set to REFRESH.

Connect to Data

After the OAuth settings file is generated, set the following properties to connect to data:

  • OAuthSettingsLocation: Set to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
  • InitiateOAuth: Set to REFRESH.

Option 2: Transfer OAuth Settings

To install the adapter on another machine, authenticate, and then transfer the resulting OAuth values:

  1. On a second machine, install the adapter and connect with the following properties set:
    • OAuthSettingsLocation: Set to a writable text file.
    • InitiateOAuth: Set to GETANDREFRESH.
    • OAuthClientId: Set to the Client ID in your app settings.
    • OAuthClientSecret: Set to the Client Secret in your app settings.
    • CallbackURL: Set to the Callback URL in your app settings.
  2. Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:
    • InitiateOAuth: Set to REFRESH.
    • OAuthSettingsLocation: Set to the path to your OAuth settings file. Make sure this file gives read and write permissions to the adapter to enable the automatic refreshing of the access token.

Configuring Access Control

If the authenticating user maps to a system-defined role, specify it in the RoleName property.

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8509