From 5cede55234013a53b3073583c50aa983b6deeecd Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 20 Jan 2026 11:37:01 -0500 Subject: [PATCH] fix: Allow browser authentication to Snowflake from the Deploy pane. The `snowflakeauth` package only permits external browser authentication from interactive contexts, which makes sense in most cases. However, push-button deployments from the RStudio IDE actually run in a separate Deploy pane, not from the interactive console -- which isn't considered "interactive" by default. So this commit tells `rlang` to temporarily treat this as an interactive context, which allows the browser flow to work. Fixes #1289. Signed-off-by: Aaron Jacobs --- NEWS.md | 3 ++- R/client-connect.R | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5fb8b704..3ef555cc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -23,7 +23,8 @@ Snowflake. * Push-button publishing from desktop RStudio is now compatible with Connect - servers hosted on Snowflake. + servers hosted on Snowflake. This includes support for browser-based + authentication during deployment. (#1289) * Added support for using identity federation to authenticate against Connect when running in Posit Workbench, when available. This allows deploying to diff --git a/R/client-connect.R b/R/client-connect.R index 87c81734..6828fc95 100644 --- a/R/client-connect.R +++ b/R/client-connect.R @@ -165,6 +165,15 @@ getSnowflakeAuthToken <- function(url, snowflakeConnectionName) { parsedURL <- parseHttpUrl(url) ingressURL <- parsedURL$host + # Detect when we're running in the Deploy pane of RStudio and enable + # "interactive" temporarily so that external browser authentication is + # permitted. + if (rstudioapi::isBackgroundJob()) { + prev <- getOption("rlang_interactive") + options("rlang_interactive" = TRUE) + on.exit(options("rlang_interactive" = prev)) + } + token <- snowflakeauth::snowflake_credentials( snowflakeauth::snowflake_connection(snowflakeConnectionName), spcs_endpoint = ingressURL