Skip to content

Conversation

@atheriel
Copy link
Collaborator

@atheriel atheriel commented Dec 16, 2025

This commit adds the machinery to support the "externalbrowser" authenticator, which is an interactive sign-in flow for users with access to a local browser. It includes session caching, which is a nice ergonomic improvement for repeated calls.

(The underlying protocol is completely bespoke to Snowflake so it took me a little while to get it actually working.)

You can test it as follows:

snowflake_connection(
  account = <account>
  user = <username>,
  authenticator = "externalbrowser"
) |> snowflake_credentials()

This should open a browser window to the account's SSO provider.

Unfortunately this is all highly interactive code, so there is not much to unit test.

@atheriel atheriel force-pushed the externalbrowser branch 3 times, most recently from 4588964 to ee88c75 Compare December 18, 2025 02:56
@aronatkins
Copy link
Contributor

I have successfully authenticated from an R/RStudio session outside Snowflake into a Snowflake-hosted Connect instance using a connection having authenticator = "externalbrowser".

rsconnect::connectSPCSUser(server="NAME", apiKey="KEY", snowflakeConnectionName = "CON")

I have not tested within Snowflake.

@atheriel
Copy link
Collaborator Author

Within Snowflake you'll get an error from this package that externalbrowser auth isn't supported (because you can't redirect to a localhost server). This is the same pattern we use in httr2 and httr for OAuth flows, so it shouldn't be too surprising to R users.

@atheriel atheriel requested a review from edavidaja December 18, 2025 15:05
@edavidaja
Copy link
Collaborator

edavidaja commented Dec 18, 2025

Okta does not seem to like the shape of whatever SAML request is getting created:
CleanShot 2025-12-18 at 11 22 25

@atheriel
Copy link
Collaborator Author

@edavidaja Any chance you're trying this from Positron or VS Code and not RStudio? I'm pretty sure I found a bug in how they handle browseURL() in the course of this.

Copy link
Collaborator

@edavidaja edavidaja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably worth noting somewhere that we don't expect this to work in Positron / VS Code or documenting the workaround. Maybe just the readme if we expect that subsequent changes there will resolve the issue.

This commit adds the machinery to support the "externalbrowser"
authenticator, which is an interactive sign-in flow for users with
access to a local browser. It includes session caching, which is a nice
ergonomic improvement for repeated calls.

(The underlying protocol is completely bespoke to Snowflake so it took me
a little while to get it actually working.)

You can test it as follows:

    snowflake_connection(
      account = <account>
      user = <username>,
      authenticator = "externalbrowser"
    ) |> snowflake_credentials()

This should open a browser window to the account's SSO provider.

Unfortunately this is all highly interactive code, so there is not much
to unit test.

Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
@atheriel
Copy link
Collaborator Author

Added a note to the README.

@atheriel atheriel merged commit eb9cbd1 into main Dec 18, 2025
10 checks passed
@atheriel atheriel deleted the externalbrowser branch December 18, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants