fix(snowflake): drop invalid session:role-any scope from OAuth flow#13061
Merged
fix(snowflake): drop invalid session:role-any scope from OAuth flow#13061
Conversation
kishanprmr
approved these changes
Apr 30, 2026
Contributor
Confidence Score: 5/5Safe to merge — minimal, well-scoped fix with no logic regressions. Two-file change: one removes a scope value that Snowflake's own docs confirm is invalid for Custom OAuth integrations, and the other is a patch version bump. No new logic paths, no data-flow changes, and the added SQL parameter ( No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(snowflake): drop invalid session:rol..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the Snowflake OAuth connection flow, which was failing for every customer with
The requested scope is invalidbefore they could even authenticate.The piece was sending
session:role-any refresh_tokenas the OAuth scope. Per Snowflake's custom OAuth docs,session:role-anyis only valid for External OAuth integrations (where another IdP like Okta or Azure issues the token). For the custom client integration that the piece's setup SQL creates (OAUTH_CLIENT = CUSTOM), the only accepted scope values arerefresh_tokenandsession:role:<ROLE_NAME>. Snowflake therefore rejected the request at/oauth/authorizebefore the user was shown the sign-in screen.This PR:
session:role-anyfrom the requested OAuth scope, leavingrefresh_token.OAUTH_USE_SECONDARY_ROLES = IMPLICITto the setup SQL so the Default Role field still works for switching to any role granted to the user after the token is issued.0.3.1 → 0.3.2.Explain How the Feature Works
After the change, the OAuth flow looks like this:
CREATE SECURITY INTEGRATIONSQL in Snowflake (now includingOAUTH_USE_SECONDARY_ROLES = IMPLICIT).https://<account>.snowflakecomputing.com/oauth/authorize?…&scope=refresh_token.snowflake.createConnection({ role })switches the session to the role configured in the Default Role field.OAUTH_USE_SECONDARY_ROLES = IMPLICITis what lets the token use any role granted to the user, so the Default Role field is no longer silently ignored.Verified end-to-end against a fresh Snowflake trial account: the previous
scope=session:role-any+refresh_tokenURL reproduces the customer's "The requested scope is invalid" error, and the patchedscope=refresh_tokenURL passes through to the sign-in screen and issues a working token.Relevant User Scenarios
OAUTH_USE_SECONDARY_ROLES = IMPLICITkeeps the Default Role field on the connection form functional after the scope change; without it, the OAuth token would be bound to the user's default role and the field would be silently ignored.Fixes # (issue)