Snowflake Security, RBAC, and User Administration · Topic 12 of 16

OAuth 2.0 in Snowflake - Snowflake OAuth, External OAuth and Custom Clients

Configure OAuth 2.0 in Snowflake: compare Snowflake OAuth with External OAuth, set up custom clients and see how network policies and private links apply.

  • 4 min
  • Includes a diagram
In a nutshell
  • Snowflake OAuth: Snowflake is the authorization server; External OAuth: Okta, Entra ID, PingFederate or custom.
  • Custom client: OAUTH_CLIENT = CUSTOM, OAUTH_CLIENT_TYPE, OAUTH_REDIRECT_URI.
  • Refresh token validity defaults to 90 days; access tokens are short.

What it is

OAuth 2.0 lets an application access Snowflake on behalf of a user without ever seeing the user's password. The user authorizes the application, the application receives an access token and, if allowed, a refresh token, and the token is used to open sessions. Access tokens are short lived (typically 10 minutes).

Snowflake supports two flavors. In Snowflake OAuth the Snowflake service is itself the authorization server. In External OAuth a separate authorization server, such as Okta, Microsoft Entra ID or PingFederate, issues the tokens and Snowflake only validates them.

Userauthorizes appthenAuthorization serverSnowflake or externalissuesAccess token and refresh tokenthenApplicationpresents tokenSnowflake session

How it works

Comparing the two

!Side by side: in Snowflake OAuth the authorization server is Snowflake, the integration is TYPE = OAUTH with a partner or custom client, and the user is the one who consents; in External OAuth an outside server such as Okta issues tokens, the integration is TYPE = EXTERNAL_OAUTH, and a token claim is mapped to LOGIN_NAME or EMAIL_ADDRESS.

AspectSnowflake OAuthExternal OAuth
Authorization serverSnowflakeOkta, Microsoft Entra ID, PingFederate or custom
IntegrationTYPE = OAUTHTYPE = EXTERNAL_OAUTH
ClientPartner (Tableau, Looker) or CUSTOMAny client of the external server
User matchThe user who consents in SnowflakeToken claim mapped to LOGIN_NAME or EMAIL_ADDRESS
Role controlRole requested at consent; blocked listScope and role in the token; blocked list
Best fitTools that talk to Snowflake directlyOne identity platform for all apps

Both are created with CREATE SECURITY INTEGRATION, which needs the CREATE INTEGRATION account privilege (ACCOUNTADMIN by default).

Snowflake OAuth for custom clients

CREATE SECURITY INTEGRATION my_app_oauth
  TYPE = OAUTH
  ENABLED = TRUE
  OAUTH_CLIENT = CUSTOM
  OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
  OAUTH_REDIRECT_URI = 'https://app.example.com/callback'
  OAUTH_ISSUE_REFRESH_TOKENS = TRUE
  OAUTH_REFRESH_TOKEN_VALIDITY = 86400
  NETWORK_POLICY = app_policy;
SELECT SYSTEM$SHOW_OAUTH_CLIENT_SECRETS('MY_APP_OAUTH');

Parameters worth knowing:

  • OAUTH_CLIENT: CUSTOM, or a partner value such as TABLEAU_DESKTOP, TABLEAU_SERVER or LOOKER.
  • OAUTH_CLIENT_TYPE: CONFIDENTIAL for clients that can keep a secret, PUBLIC for clients on user devices. Required for custom clients.
  • OAUTH_REDIRECT_URI: required for custom clients; it must use TLS unless OAUTH_ALLOW_NON_TLS_REDIRECT_URI is TRUE (not recommended).
  • OAUTH_ISSUE_REFRESH_TOKENS: default TRUE; if FALSE users must reauthorize each time.
  • OAUTH_REFRESH_TOKEN_VALIDITY: default 7776000 seconds (90 days).
  • BLOCKED_ROLES_LIST: roles that cannot be consented to. By default ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN and SECURITYADMIN are blocked.
  • PRE_AUTHORIZED_ROLES_LIST: roles users need not consent to; confidential clients only.
  • OAUTH_USE_SECONDARY_ROLES: IMPLICIT activates default secondary roles; NONE is the default.
Register clientCREATE SECURITY INTEGRATIONthenGet client ID and secretSYSTEM$SHOW_OAUTH_CLIENT_SECRETSthenUser consentsthenTokens issuedthenRefresh before expiry
Watch out

Privileged roles are blocked by default. A client that cannot use SECURITYADMIN or ACCOUNTADMIN is working as designed, not misconfigured.

External OAuth

CREATE SECURITY INTEGRATION ext_oauth_okta
  TYPE = EXTERNAL_OAUTH
  ENABLED = TRUE
  EXTERNAL_OAUTH_TYPE = OKTA
  EXTERNAL_OAUTH_ISSUER = 'https://example.okta.com/oauth2/aus123'
  EXTERNAL_OAUTH_JWS_KEYS_URL = 'https://example.okta.com/oauth2/aus123/v1/keys'
  EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM = 'sub'
  EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE = 'LOGIN_NAME';
  • EXTERNAL_OAUTH_TYPE: OKTA, AZURE, PING_FEDERATE or CUSTOM.
  • The token claim is mapped to the Snowflake user's LOGIN_NAME or EMAIL_ADDRESS, so the user must already exist.
  • EXTERNAL_OAUTH_ANY_ROLE_MODE: DISABLE (default), ENABLE, or ENABLE_FOR_PRIVILEGE (needs the USE_ANY_ROLE privilege on the integration).
  • EXTERNAL_OAUTH_BLOCKED_ROLES_LIST blocks the same privileged roles by default.

Effects of federation, network policies and private connectivity

FactorEffect on Snowflake OAuth
Federated authentication (SSO)The browser authorization step can hand off to the IdP, so users sign in with SSO during consent
Network policy on the integration (NETWORK_POLICY)Controls token requests, refresh and use of access tokens
Network policy on the userControls browser based authentication; it is not considered for token requests to custom clients
Local applicationsThe built in SNOWFLAKE$LOCAL_APPLICATION integration also checks the user policy on token requests; precedence is user, then integration, then account
Private connectivitySaaS clients use the public account URL for token requests; USE_PRIVATELINK_FOR_AUTHORIZATION_ENDPOINT redirects the browser authorization step to the private URL
Exam tip

When a scenario says OAuth works in the browser but token requests fail, check the integration network policy. Browser sign in follows the user policy, while token requests from a custom client follow the integration policy, or the account policy if none is set.

Common mistakes

Mixing up the two flavors. Snowflake issues the tokens in Snowflake OAuth; an external server issues them in External OAuth.

Forgetting to create users for External OAuth. The claim must map to an existing user.

Confusing refresh and access token lifetimes. OAUTH_REFRESH_TOKEN_VALIDITY governs the refresh token, not the short access token.

Expecting blocked roles to work. ACCOUNTADMIN and similar roles are blocked by default.

What to remember for the exam

  • Snowflake OAuth: Snowflake is the authorization server; External OAuth: Okta, Entra ID, PingFederate or custom.
  • Custom client: OAUTH_CLIENT = CUSTOM, OAUTH_CLIENT_TYPE, OAUTH_REDIRECT_URI.
  • Refresh token validity defaults to 90 days; access tokens are short.
  • Privileged roles are blocked by default in both flavors.
  • OAuth network policies: the user policy governs browser sign in; the integration policy governs token requests and token use; local applications check user, then integration, then account.

Check yourself

  • Who issues tokens in External OAuth?

    The external authorization server, such as Okta or Microsoft Entra ID.

  • What retrieves the client ID and secret of a Snowflake OAuth integration?

    SYSTEM$SHOW_OAUTH_CLIENT_SECRETS with the integration name.

  • Which network policy governs browser sign in during Snowflake OAuth consent?

    The policy on the user; the integration policy governs token requests and token use.

Topic 12 of 16 in Snowflake Security, RBAC, and User Administration

Test yourself on Snowflake Security, RBAC, and User Administration

The full Snowflake ADA-C02 question bank has 814 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.