Python Connector for Snowflake

Obtaining credentials for OAuth 2.0 authentication - Python Connector for Snowflake

Obtaining credentials for OAuth 2.0 authentication

To use OAuth 2.0 authentication with Snowflake, create a security integration and obtain the client ID and client secret required for the connection.

Create an OAuth security integration in Snowflake

  1. In Snowflake, open a worksheet.
  2. Run the following script. Replace <your_integration> with a name for the security integration.
    USE ROLE ACCOUNTADMIN;
    CREATE SECURITY INTEGRATION <your_integration>
    TYPE = OAUTH
    ENABLED = TRUE
    OAUTH_CLIENT = CUSTOM
    OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
    OAUTH_REDIRECT_URI = 'http://localhost:59099'
    OAUTH_ISSUE_REFRESH_TOKENS = TRUE
    OAUTH_REFRESH_TOKEN_VALIDITY = 7776000;
    

    OAUTH_REFRESH_TOKEN_VALIDITY specifies the refresh token validity period in seconds. The value can range from 86400 (1 day) to 7776000 (90 days). The default value is 7776000 (90 days).

View the OAuth security integration

To verify that the security integration was created successfully, run the following script:

USE ROLE ACCOUNTADMIN;
DESC SECURITY INTEGRATION <your_integration>;

Get the client ID and client secret

  1. Run the following script to obtain the client ID and client secret for the security integration:
    USE ROLE ACCOUNTADMIN;
    SELECT system$show_oauth_client_secrets('<your_integration>');
    
  2. Copy the returned client ID and client secret.
  3. Use the client ID and client secret in the ClientId and ClientSecret arguments when signing in and connecting. For more information, see Connecting to Snowflake.
© 2022-2026 Devart. All Rights Reserved. Request Support Python Connectors Forum Provide Feedback