Pass variables to shiny app?

I want to bundle a shiny app in one of my package, and I want the function that call the shiny app to take some variables as input and pass it to the app.

This is the function that I created to call my shiny app:

MyShinyApp <- function(username, password, workspace) {
  shiny::runApp(system.file('MyShinyApp', package='MyPackage'))
}

Alas, I cannot figure out how to pass those variables to the shiny app. I tried adding them to the runApp command and to shinyServer( function(input, output, session) but it didn't work.

Can you point me in the right direction?

Thanks!

I'm not sure if there is a better way, but this does the trick.

MyShinyApp <- function(username, password, workspace) {
  .GlobalEnv$.username <- username
  .GlobalEnv$.password <- password
  .GlobalEnv$.workspace <- workspace
  on.exit(rm(list=c(.username, .password, .workspace), envir=.GlobalEnv))
  shiny::runApp(system.file('MyShinyApp', package='MyPackage'))
}

And then I use the global variables inside my app.