Workbench-managed Snowflake Credentials

Workbench | Enhanced Advanced

Posit Workbench has a native integration for Snowflake that includes support for managed Snowflake OAuth credentials. See The Snowflake AI Data Cloud - Mobilize Data, Apps, and AI for more information on Snowflake.

Workbench-managed Snowflake credentials allow you to sign in with a Snowflake role and account from the home page and be immediately granted access to data warehouses and compute resources using your existing Snowflake identity. Managed credentials avoid the burden (and risk) of manually entering your Snowflake credentials when connecting to Snowflake.

Workbench-managed Snowflake credentials are refreshed automatically while your session is active.

Starting a Session with Workbench-managed Snowflake credentials

See Starting a Session with Workbench-managed credentials for more information on how to enable Snowflake credentials for use in new sessions. If the Snowflake selection is not available, then your administrator has not configured the integration.

Signing into Snowflake Roles and Accounts

The Snowflake integration provides a few extra controls for interacting with roles.

For users who have not yet authenticated with Snowflake an initial sign-in is required with either the default role of the intended account, or by manually specifying a known role using the “Add Role” mode. After this, Workbench obtains a token for that account which allows it to query other roles available to you, as well as sign you in as those roles while using your new session. From the New Session dialog, open the Edit Credentials dialog and select the “Default Role” under the Snowflake account that you want to sign in with.

Selecting a Default Role under a Snowflake Account

This begins the authentication flow. Once that account is signed in, the default role under that account is resolved and added to the list.

Showing the discovered default role under a Snowflake Account after signing in

Manually Refreshing Roles

If configured by your administrator, refreshing roles may be available. This enables the refresh control on the left side of the role drop-down, and clicking it requests all roles from each signed-in account. Additionally, if this feature is enabled, all roles under the account are automatically discovered and added to the list as soon as you sign in with that account.

Showing all roles discovered under a Snowflake Account after signing in

Manually Specifying Roles

When automatic role discovery is disabled by the administrator, you can still manually add an existing role from the target Snowflake account by clicking on the “Add Role” button next to the drop-down. This switches into the manual role mode. Ensure that the correct account is selected in the drop-down under Snowflake Account. Specifying a role name is optional – an empty role here performs the same action as signing in with the default role. In this mode, clicking “Add Role” proceeds with the sign-in flow.

Showing the add role mode for a Snowflake account

Manually specifying a role for a Snowflake account

If a role was specified, then a temporary role is added to the list of credentials, but it remains disabled until sign-in is complete. It is removed if the sign-in fails.

Showing a pending manual role “NEW_ROLE” as a placeholder under the POSIT_SOFTWARE_PBC account

Just like the sign-in process, the add-role process can be canceled with the “X” button after the sign-in flow is initiated.

Showing the “X” – cancel add role – button after clicking “Add Role”

Snowflake CLI

The Snowflake CLI wraps Snowflake SQL and provides configuration management and data access tools. For more information, see the Snowflake CLI reference. Configuring Snowflake connections and credentials is unnecessary when using the CLI with managed Snowflake credentials inside Posit Workbench.

# List connections
snow connection list
# Test the default connection
snow connection test

Snowflake with R

Workbench-managed Snowflake credentials have been validated to work with odbc. odbc version 1.5.0 or higher provides odbc::snowflake() which automatically handle many common authentication scenarios. Pair odbc with DBI if you want to write your own SQL:

library(DBI)
library(odbc)

conn <- DBI::dbConnect(odbc::snowflake())
DBI::dbGetQuery(conn, "SELECT CURRENT_USER()")

Or, to connect to a specific warehouse, database, and schema:

DBI::dbConnect(
  odbc::snowflake(),
  warehouse = "DEFAULT_WH",
  database = "WEB_TRAFFIC_FOUNDATION_EXPERIMENTAL",
  schema = "CYBERSYN"
)

Snowflake with Python

Workbench-managed Snowflake credentials work with the Snowflake connector library provided by Snowflake. See the Snowflake Connector for Python section of Snowflake’s documentation for more information. No additional configuration is necessary when implementing the connector in code.

pip install snowflake-connector-python
test_connection.py
import snowflake.connector

with snowflake.connector.connect() as conn:
    with conn.cursor() as cur:
        print(cur.execute("SELECT 'successfully connected to ' || current_account() || ' WITH user ' || current_user();").fetchall())
python3 test_connection.py
Back to top