CertSafari
    Snowflake SnowPro Advanced: Administrator (ADA-C02)· Lessons

    Domain 1 · Lesson 5/24

    Key-pair, PAT and OAuth authentication in Snowflake

    Set up and manage Snowflake authentication.

    15 min read
    4.43% of exam
    12 sources
    Published 20 Oct 2026
    Docs as of 18 Oct 2026

    What you will be able to do

    • Assign RSA public keys to a user and rotate them without downtime, using either the legacy key properties or named key pairs
    • Create, restrict, expire and rotate programmatic access tokens, and meet their network policy requirement
    • Choose between Snowflake OAuth and External OAuth and configure Snowflake OAuth for a custom client
    • Predict how network policies, private connectivity and SSO affect a Snowflake OAuth flow

    1.Key-pair authentication and zero-downtime rotation

    Programmatic clients and SERVICE users can't respond to an MFA prompt, so they prove their identity with a secret they hold. A key pair is the oldest of these methods. The client keeps an RSA private key, Snowflake stores the matching public key on the user, and Snowflake checks each connection's private key against it. To assign a key you need OWNERSHIP of the user or the MODIFY PROGRAMMATIC AUTHENTICATION METHODS privilege on it. The privilege lets a custom role manage keys for one service user without owning it.

    Snowflake has two ways to store public keys. Named key pairs, added with ALTER USER ... ADD KEY PAIR, are recommended and support role restriction and expiration. The legacy way uses two user properties, RSA_PUBLIC_KEY and RSA_PUBLIC_KEY_2, set with ALTER USER. You leave out the PEM delimiters, and neither property supports role restriction or expiration. There are two properties so you can replace a key without an outage:

    1. Generate a new key pair and put the public key in whichever of the two properties is empty.
    2. Point the client at the new private key. Snowflake matches whichever public key fits the private key presented, so clients on the old key and clients on the new key both connect in the meantime.
    3. Remove the old public key from the user.
    Step 1: put the new public key in the unused slotsql
    ALTER USER example_user SET RSA_PUBLIC_KEY_2='JERUEHtcve...';
    Step 3: remove the old key once every client has switchedsql
    ALTER USER example_user UNSET RSA_PUBLIC_KEY;

    A named key pair rotates in a single statement. ALTER USER ... ROTATE KEY PAIR stores the new public key under the same name and keeps the old one, renamed with a _ROTATED_ suffix, for a grace period of 24 hours by default. EXPIRE_ROTATED_KEY_PAIR_AFTER_HOURS = 0 disables the old key immediately, which is what you want when a private key may have leaked. During the grace period both keys count toward the limit of 10 key pairs per user.

    Rotating a named key pair and disabling the old key immediatelysql
    ALTER USER IF EXISTS example_user ROTATE KEY PAIR my_key
      PUBLIC_KEY = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgK...'
      EXPIRE_ROTATED_KEY_PAIR_AFTER_HOURS = 0;

    Checkpoint 1 of 5· Check yourself

    A nightly ETL job runs on a server and connects as a Snowflake user with TYPE = SERVICE. Which way of authenticating can this job use?

    Sources12

    2.Programmatic access tokens

    A programmatic access token (PAT) is a secret that Snowflake generates for one user. You can use it in place of a password, for example in a driver's password argument or the password field in Tableau or Power BI. You can also send it as a bearer token in the Authorization header of REST and SQL API calls. You create it with ALTER USER ... ADD PROGRAMMATIC ACCESS TOKEN, or the shorter PAT keyword. The secret appears only once, in the token_secret column of that command's output.

    A token limited to one role that expires after 15 dayssql
    ALTER USER IF EXISTS example_user ADD PROGRAMMATIC ACCESS TOKEN example_token
      ROLE_RESTRICTION = 'example_role'
      DAYS_TO_EXPIRY = 15;

    ROLE_RESTRICTION sets the role used to evaluate privileges and to own any objects the token creates. Secondary roles are not used. The role must already be granted to the user. The parameter is required by default for SERVICE users and optional for PERSON users. If the role is later revoked or dropped, the token stops working. DAYS_TO_EXPIRY defaults to 15 and can't be changed after the token is created; to change it, revoke the token and generate a new one. Each user can have at most 15 tokens, including disabled ones.

    PATs also have a network requirement that passwords don't. By default, the token's user must be subject to a network policy, set on the user or on the account, unless an authentication policy changes that requirement. For a PERSON user with no network policy, MINS_TO_BYPASS_NETWORK_POLICY_REQUIREMENT waives the requirement for 1 to 1440 minutes. It never lets the user get around a network policy that is in force. To use PATs from a third-party tool, create a network policy that allows the tool's IP ranges.

    ALTER USER ... ROTATE PROGRAMMATIC ACCESS TOKEN issues a new secret with the token's original DAYS_TO_EXPIRY. The old secret stays valid for EXPIRE_ROTATED_TOKEN_AFTER_HOURS, which is 24 by default; set it to 0 to expire the old secret immediately. You can't rotate a token from a session that authenticated with a PAT for the same user.

    Syntax for rotating a PATsql
    ALTER USER [ IF EXISTS ] [ <username> ] ROTATE { PROGRAMMATIC ACCESS TOKEN | PAT } [ IF EXISTS ] <token_name>
      [ EXPIRE_ROTATED_TOKEN_AFTER_HOURS = <integer> ]

    Checkpoint 2 of 5· Check yourself

    An administrator runs ALTER USER ... ADD PROGRAMMATIC ACCESS TOKEN for a service user and closes the result pane without copying anything. What now?

    Sources345

    3.Snowflake OAuth vs External OAuth

    With OAuth 2.0, a client acts for a user by presenting a short-lived access token instead of a stored credential. Snowflake supports two variants, and they differ in who runs the authorization server. With Snowflake OAuth, Snowflake is the authorization server, and the client runs the OAuth 2.0 authorization code flow through a browser. With External OAuth, an outside server such as Okta, Entra ID or a custom one issues the token, and Snowflake only validates it. In both cases the driver sets authenticator = oauth.

    Snowflake OAuth and External OAuth compared
    CategorySnowflake OAuthExternal OAuth
    Security integration syntaxcreate security integration type = oauth ...create security integration type = external_oauth
    OAuth flowOAuth 2.0 code grant flowAny OAuth flow that the client can initiate with the External OAuth server
    Client application browser accessRequiredNot required
    Programmatic clientsRequires a browserBest fit
    Driver propertyauthenticator = oauthauthenticator = oauth

    Choose External OAuth when your IdP already issues the tokens and the clients have no browser. Choose Snowflake OAuth when you need a network policy that applies only to the integration, because External OAuth integrations can't have one; only account-wide policies apply to them. External OAuth maps each token to a user through a claim. external_oauth_token_user_mapping_claim names the claim, for example 'upn' or 'sub', and external_oauth_snowflake_user_mapping_attribute = 'login_name' matches its value to the user's LOGIN_NAME. Either way, OAuth logins appear in the login history with FIRST_AUTHENTICATION_FACTOR set to OAUTH_ACCESS_TOKEN.

    Checkpoint 3 of 5· Match them up

    Match each item to the OAuth variant or fact it belongs with.

    Tap a term, then the definition that fits it.

    Sources67

    4.Configuring Snowflake OAuth for a custom client

    A custom client, meaning an application your own organization builds, gets a Snowflake OAuth integration with OAUTH_CLIENT = CUSTOM. OAUTH_CLIENT_TYPE says whether the client can keep a secret: CONFIDENTIAL for a protected service running in the cloud, PUBLIC for an app on a desktop or distributed through an app store. OAUTH_REDIRECT_URI is required. It must match the redirect_uri the client sends, without the query parameters; otherwise the request fails with OAUTH_AUTHORIZE_INVALID_REDIRECT_URI. Use OAUTH_ALTERNATE_REDIRECT_URIS to register additional redirect URIs.

    The start of the custom-client integration syntaxsql
    CREATE [ OR REPLACE ] SECURITY INTEGRATION [IF NOT EXISTS]
      <name>
      TYPE = OAUTH
      OAUTH_CLIENT = CUSTOM
      OAUTH_CLIENT_TYPE = 'CONFIDENTIAL' | 'PUBLIC'
      OAUTH_REDIRECT_URI = '<uri>'
      [ ENABLED = { TRUE | FALSE } ]
      [ OAUTH_ALLOW_NON_TLS_REDIRECT_URI = { TRUE | FALSE } ]
      [ OAUTH_ALTERNATE_REDIRECT_URIS = ( '<uri>' [ , '<uri>' , ... ] ) ]

    Token lifetimes are set on the integration. OAUTH_ACCESS_TOKEN_VALIDITY defaults to 600 seconds (10 minutes) and accepts 60 to 3600. OAUTH_REFRESH_TOKEN_VALIDITY defaults to 7776000 seconds (90 days), with a minimum of 3600, and only applies while OAUTH_ISSUE_REFRESH_TOKENS is TRUE. If OAUTH_ISSUE_REFRESH_TOKENS is FALSE, the user has to authenticate again each time the access token expires. Turn on OAUTH_SINGLE_USE_REFRESH_TOKENS_REQUIRED to protect against stolen refresh tokens.

    The integration also controls roles. ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN and SECURITYADMIN are blocked by default, and BLOCKED_ROLES_LIST blocks others. After authenticating, the user consents to the role the client requests. A SECURITYADMIN or higher role can pre-authorize that consent with ALTER USER ... ADD DELEGATED AUTHORIZATION. A client that authenticates to the token endpoint with a JWT instead of a client secret registers its public key in OAUTH_CLIENT_RSA_PUBLIC_KEY. The _2 property rotates it the same way user keys rotate:

    Adding the client's new public key in the second slot before removing the firstsql
    alter integration myint set oauth_client_rsa_public_key_2='JERUEHtcve...';

    Checkpoint 4 of 5· Check yourself

    A custom client's integration sets OAUTH_ISSUE_REFRESH_TOKENS = FALSE. The access token has just expired after its default lifetime. What happens next?

    Sources8910

    5.How network policies, private connectivity and SSO affect Snowflake OAuth

    A Snowflake OAuth flow uses two network paths, and a different policy controls each one. The evaluation rules themselves are covered in Network policy evaluation and precedence. The integration's NETWORK_POLICY controls the client's traffic: exchanging an authorization code for tokens, refreshing tokens, and querying Snowflake with an access token. The user's browser signing in at the authorization server is controlled by the user's network policy, or by the account's policy if the user has none. A token request blocked by a network policy can return the invalid_client error. The built-in SNOWFLAKE$LOCAL_APPLICATION integration is the exception: for its token requests, Snowflake checks the user's policy, then the integration's, then the account's.

    A Snowflake OAuth integration with its own network policysql
    CREATE SECURITY INTEGRATION td_oauth_int2
      TYPE = oauth
      ENABLED = true
      OAUTH_CLIENT = tableau_desktop
      OAUTH_REFRESH_TOKEN_VALIDITY = 36000
      BLOCKED_ROLES_LIST = ('SYSADMIN')
      NETWORK_POLICY = 'allow_private_ip_only';

    Private connectivity splits along the same two paths. SYSTEM$GET_PRIVATELINK_CONFIG returns the account's privatelink URL; the endpoints themselves are covered in Private connectivity (PrivateLink / Private Service Connect). A client running on the user's own network can use that URL for every step. A SaaS client cannot. Its token request comes from the vendor's servers on the public internet, which can't resolve a privatelink hostname, so the token endpoint must be the public account URL. Setting USE_PRIVATELINK_FOR_AUTHORIZATION_ENDPOINT = TRUE sends only the user's authorization step over private connectivity. The client's own calls, including its first request to the authorization endpoint, still go over the public internet. Tableau Cloud over private connectivity needs OAUTH_CLIENT = CUSTOM instead of the partner value, and Looker can't use Snowflake OAuth over private connectivity.

    Federated authentication comes in at the authorization step. Users who authorize a Snowflake OAuth client sign in through the Snowsight login interface, so their normal Snowsight sign-in rules apply. An SSO user signs in at the IdP, and a password user must be enrolled in MFA.

    Checkpoint 5 of 5· Check yourself

    Your account opted out of mandatory MFA with an account-level authentication policy that sets MFA_ENROLLMENT=OPTIONAL. A user who signs in with a Snowflake password, not SSO, is asked to authorize a custom Snowflake OAuth client. What does that user need at the authorization step?

    Sources108611

    Practise it for real

    Rotate a user's legacy RSA key without interrupting the clients that connect with it

    1. 1.Generate an encrypted private key: openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 aes-256-cbc -inform PEM -out rsa_key.p8

      Why: Encrypting the key file with a passphrase protects it at rest. AES-256-CBC is the recommended cipher.

      You should see: A PEM file that starts with -----BEGIN ENCRYPTED PRIVATE KEY-----

    2. 2.Derive the public key: openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub

      Why: Only the public half goes to Snowflake.

      You should see: A PEM file that starts with -----BEGIN PUBLIC KEY-----

    3. 3.Run ALTER USER example_user SET RSA_PUBLIC_KEY_2='MIIBIj...' with the body of rsa_key.pub between the quotes and without the BEGIN and END lines (use RSA_PUBLIC_KEY if that slot is the empty one)

      Why: Putting the new key in the empty slot leaves the old key working while clients switch over.

      You should see: DESC USER example_user shows a fingerprint for the second key alongside the first

    4. 4.Compare the fingerprint from DESC USER with the output of openssl rsa -pubin -in rsa_key.pub -outform DER | openssl dgst -sha256 -binary | openssl enc -base64

      Why: Matching fingerprints confirm Snowflake stored the key you generated.

      You should see: Both commands print the same base64 string

    5. 5.Point each client at rsa_key.p8, then run ALTER USER example_user UNSET RSA_PUBLIC_KEY

      Why: Snowflake matches whichever stored public key fits the private key presented, so removing the old key last avoids any downtime.

      You should see: Clients on the new key keep connecting, and any client still using the old private key is rejected

    Stuck? Get a nudge

    If a client fails after step 5, check which private key file it loads before you look for a problem in Snowflake.

    Sources

    (12)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Set the public key value to either RSA_PUBLIC_KEY or RSA_PUBLIC_KEY_2, whichever key value is not currently in use.”
      ↩︎ Key-pair authentication and zero-downtime rotation
      “This approach does not support role restriction or expiration.”
      ↩︎ Key-pair authentication and zero-downtime rotation
      “By default, the prior key remains valid for 24 hours.”
      ↩︎ Key-pair authentication and zero-downtime rotation
      “Set the public key value to either RSA_PUBLIC_KEY or RSA_PUBLIC_KEY_2, whichever key value is not currently in use.”
      ↩︎ Exam trap 1
    2. 2.
      “Rotate a key pair and immediately expire the prior key pair (useful when responding to a suspected private-key compromise):”
      ↩︎ Key-pair authentication and zero-downtime rotation
      “The names PUBLIC_KEY_1 and PUBLIC_KEY_2 are reserved for keys assigned with the legacy RSA_PUBLIC_KEY and RSA_PUBLIC_KEY_2 user properties”
      ↩︎ Prediction
    3. 3.
      “the user associated with the token must be subject to a network policy”
      ↩︎ Programmatic access tokens
      “After you create a programmatic access token, you cannot change the expiration date.”
      ↩︎ Programmatic access tokens
      “The output of this command is the only place where the token appears.”
      ↩︎ Checkpoint
    4. 4.
      “Each user can have a maximum of 15 programmatic access tokens.”
      ↩︎ Programmatic access tokens
      “Setting MINS_TO_BYPASS_NETWORK_POLICY_REQUIREMENT does not allow users to bypass the network policy itself.”
      ↩︎ Exam trap 2
    5. 5.
      “You cannot rotate a programmatic access token in a session where you used a programmatic access token for the same user for authentication.”
      ↩︎ Programmatic access tokens
    6. 6.
      “Programmatic clients | Requires a browser | Best fit”
      ↩︎ Snowflake OAuth vs External OAuth
      “the FIRST_AUTHENTICATION_FACTOR column in the output has the value OAUTH_ACCESS_TOKEN”
      ↩︎ Snowflake OAuth vs External OAuth
      “To determine the account URL to use with private connectivity to the Snowflake service, call the SYSTEM$GET_PRIVATELINK_CONFIG function.”
      ↩︎ How network policies, private connectivity and SSO affect Snowflake OAuth
    7. 7.
      “Currently, network policies cannot be added to your External OAuth security integration.”
      ↩︎ Snowflake OAuth vs External OAuth
      “Currently, network policies cannot be added to your External OAuth security integration.”
      ↩︎ Exam trap 3
    8. 8.
      “Minimum: 60 (1 minute) Maximum: 3600 (1 hour) Default: 600 (10 minutes)”
      ↩︎ Configuring Snowflake OAuth for a custom client
      “By default, Snowflake prevents the ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN, and SECURITYADMIN roles from authenticating.”
      ↩︎ Configuring Snowflake OAuth for a custom client
      “Interactions between Snowflake and the client, including the initial request to the authorization endpoint, still happen over the public internet.”
      ↩︎ How network policies, private connectivity and SSO affect Snowflake OAuth
      “If set to FALSE, a refresh token is not issued. User consent is revoked, and the user must confirm authorization again.”
      ↩︎ Checkpoint
    9. 9.
      “Without this delegated authorization, a user must authorize consent for the role after authentication.”
      ↩︎ Configuring Snowflake OAuth for a custom client
    10. 10.
      “redirect_uri given as a parameter to the authorization endpoint does not match the redirect_uri of the integration”
      ↩︎ Configuring Snowflake OAuth for a custom client
      “A network policy associated with the Snowflake OAuth security integration does not affect network traffic between the user and Snowflake as the authorization server.”
      ↩︎ How network policies, private connectivity and SSO affect Snowflake OAuth
      “The token endpoint must therefore be a public Snowflake URL.”
      ↩︎ How network policies, private connectivity and SSO affect Snowflake OAuth
    11. 11.
      “Because users authenticating with Snowflake OAuth use the Snowsight login interface, they must be enrolled in MFA.”
      ↩︎ How network policies, private connectivity and SSO affect Snowflake OAuth

    Also cited

    Ready to test yourself?

    Practise the 16 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.