Pass custom arguments to the Shiny app

Dear Tobias and Frederick,

Thank you for ShinyProxy! The question: What is the best way to pass custom arguments to the Shiny app?
In our use-case, shinyproxy would sit behind a CMS, and we want to avoid ldap authentication - however, we would like to know the user name inside the shiny app. We are aware that shinyproxy passes the user name to the Shiny app as an environment variable (“SHINYPROXY_USERNAME”), but this seems to be a random hash if ldap authentication is set to “none” in the application.yml file. (Of course shinyproxy can not be aware of the CMS-authentication by default.)

What would be the smartest way to pass the name of the user via ShinyProxy? And in general; what is the best way to pass custom arguments to the Shiny app if we want to use ShinyProxy?

Cheers,
Denes

Hi @tdenes

Thank you for your question!

I think it is best to use a pure Shiny mechanism (i.e. independently of ShinyProxy) e.g. passing information via the URL and retrieving it in the session$clientData$url_search variable. See http://shiny.rstudio.com/articles/client-data.html

Is that useful?

Best,
Tobias

Hi Tobias,

We had the same idea, but it seems you can not retrieve URL queries if the Shiny app is run by ShinyProxy.
Here is a MRE:

ui.R:

library(shiny)
tagList(
tags$h1("Hostname: "),
textOutput(“hostname”),
tags$h1("Port: "),
textOutput(“port”),
tags$h1("Query: "),
textOutput(“query”)
)


server.R

library(shiny)
function(input, output, session) {
output$hostname <- renderText(session$clientData$url_hostname)
output$port <- renderText(session$clientData$url_port)
output$query <- renderText(session$clientData$url_search)
}


If you run the code above in pure Shiny or in a dockerised version, e.g.:
sudo docker run -p 3838:3838 shinyproxy/urlexample R -e “shiny::runApp(’/root/urlexample’)”, you can add arbitrary query string which is displayed as expected (e.g., for 0.0.0.0:3838/?user=user1, the query field is populated by ‘?user=user1’). However, this is not the case if I run it via ShinyProxy, and type e.g.: http://0.0.0.0:8080/app/urlexample?user=user1 (the query part is simply ignored).

Thanks @tdenes ! We will fix this and let you know!

@tdenes this is now fixed in release 0.7.5 - thanks again for the reproducible example.

Perfect, thank you for the rapid fix!

Hello,
we are dealing with slight variation on this problem: we get the url search parameters from the url when the app is running via the session$clientData$url_search variable. We want this to be used as a link to share between users (e.g. like sharing the map position on maps.google.com). It works when the user is logged in, he pastes the url and it gets him where he wants. But when the user is not logged in, it takes him to the login screen, he writes password, it forwards him to the right shiny app, the search parameter is in the url but doesn’t get caught by the variable observer.

EDIT: Another thing is, that although we see the expected url, and the $hostname and $pathname are the same, the $pathname variable does not containe the expected /app/appname, but the name of the docker container.
Thanks
Jan