Reading SHINYPROXY_OIDC_ACCESS_TOKEN in app


#1

Hi,

I’ve set up an app with ShinyProxy (v2.1.0) and a Shiny App both in containers with a nginx server.

I’m having some issues reading SHINYPROXY_OIDC_ACCESS_TOKEN in my shiny app. In my app, I’ve printed the names of the environment variables with:

output$test <- renderText({ names(Sys.getenv()) })

and get:

EDITOR HOME LANG LD_LIBRARY_PATH LN_S LOG_FILE MAKE OLDPWD PAGER PATH PWD R_ARCH R_BROWSER R_BZIPCMD R_DOC_DIR R_GZIPCMD R_HOME R_INCLUDE_DIR R_LIBS R_LIBS_SITE R_LIBS_USER R_PAPERSIZE R_PDFVIEWER R_PLATFORM R_PRINTCMD R_RD4PDF R_SESSION_TMPDIR R_SHARE_DIR R_SYSTEM_ABI R_TEXI2DVICMD R_UNZIPCMD R_ZIPCMD RSTUDIO_PANDOC SED SHINY_APP SHINY_GAID SHINY_MODE SHINY_PORT SHINY_SERVER_VERSION SHINY_SHARED_SECRET SHLVL TAR WORKER_ID

There is no SHINYPROXY_OIDC_ACCESS_TOKEN. What am I missing? What is the way to read the token?

I have entered into the running container’s R session and the access token, username and usergroups environment variables are all listed, the variables are passed to the App’s container.

Thanks,
Paul

Application.yml:

proxy:
  authentication: openid
  openid:
    auth-url: https://accounts.google.com/o/oauth2/v2/auth
    token-url: https://www.googleapis.com/oauth2/v4/token
    jwks-url: https://www.googleapis.com/oauth2/v3/certs
    client-id: xxx.apps.googleusercontent.com
    client-secret: xxx
  title: PGS Shiny Proxy
  hide-navbar: false
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 600000
  port: 8080
  docker:
    internal-networking: true
  specs:
  - id: webapp
    display-name: Web App
    description: Web App - Shiny
    container-cmd: ["/usr/bin/shiny-server.sh"]
    container-image: app/shiny
    container-network: pgs_net
    container-env:
      user: 'shiny'
      environment:
        - APPLICATION_LOGS_TO_STDOUT=false

logging:
  file:
    shinyproxy.log

#2

Hi @Paul_Stevenson,

It appears that you are using shiny-server inside your container. And it strips environment variables for security reasons (see https://groups.google.com/forum/#!topic/shiny-discuss/nNs0kztwdWo).
If you can’t achieve what you want with ‘pure’ shiny, there are some possible solutions for shiny-server described in https://community.rstudio.com/t/passing-environment-variable-to-an-app-in-shiny-server/13355 and older thread Logged in user info in Shiny App.


#3

@Paul_Stevenson As @mnazarov points out, ShinyProxy does not require shiny server to be used and its use is not recommended. Apps can be launched as pure Shiny apps as described in https://www.shinyproxy.io/deploying-apps/

Hope this helps,
Tobias