Is there a way to detect if an app is running on

I wondered if there was an environment argument or similar to detect if the Shiny app is running on Reason being I need to enact special behaviour for applications for my authentication flows based on this OAuth2 flow by Joe Cheng.

Locally and on my local Shiny server applications everything works ok, but on the applications are running without loading the options set, defaulting to the package default, as well as the Rook request is not reading the URL, instead showing a localhost URL with a random port number I can't detect before deploying the app. I would like to give users the option to hardcode the URL to redirect too, but only if the application is on An example is this test deployment which is running the below code:


## attempt to set options
options(googleAuthR.webapp.client_id = "",
        googleAuthR.webapp.client_secret = "XXX",
        googleAuthR.scopes.selected = "",
        googleAuthR.client_id = "",
        googleAuthR.client_secret = "XXXX",
        googleAuthR.verbose = 1)

log_option <- function(x){
  cat("\n Option: ",x, " ",getOption(x))

## ui.R
ui <- fluidPage(title = "googleAnalyticsR Test Deployment",

## server.R
server <- function(input, output, session){

  al <- reactive(ga_account_list())
  view_id <- callModule(authDropdown, "auth_menu", ga.table = al)
  output$viewid <- renderText(view_id())
  output$client_id <- renderText(getOption("googleAuthR.webapp.client_id"))


shinyApp(gar_shiny_ui(ui, login_ui = silent_auth), server)

1 Like

The recommended approach here is to use the config package (which is set to shinyapps on

Some docs on the topic, focused on databases but relevant for any code that you might need to alter based on environment:

Explained generically here as well:


Great thanks! Will check that out.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.