Closed aldomann closed 3 years ago
gar_shiny_ui
is doing similar to golem here in that it takes a UI object and makes it a function so this would work:
library(shiny)
googleAuthR::gar_set_client(web_json = Sys.getenv("GAR_CLIENT_WEB_JSON"), activate = "web")
ui_obj <- tagList(
# Leave this function for adding external resources
# golem_add_external_resources(),
# List the first level UI elements here
fluidPage(
h1("authtest")
)
)
app_server <- function(input, output, session) {
# this is not reactive, no need as you only reach here authenticated
googleAuthR::gar_shiny_auth(session)
# List the first level callModules here
}
shinyApp(
ui = googleAuthR::gar_shiny_ui(ui_obj),
server = app_server
)
I will have to think more about how to integrate them both and may need Colin's help at golem :) Untested but perhaps this?
app_ui <- function(request) {
googleAuthR::gar_set_client(web_json = Sys.getenv("GAR_CLIENT_WEB_JSON"), activate = "web")
ui_obj <- tagList(
# Leave this function for adding external resources
# golem_add_external_resources(),
# List the first level UI elements here
fluidPage(
h1("authtest")
)
)
# output a function that takes request
f <- googleAuthR::gar_shiny_ui(ui_obj),
f(request)
}
That works beautifully, tested both in the minimal example, and in a complete {golem} package.
What goes wrong
I've been following the example on Create a Google login before your Shiny UI launches, and while it works great when using
ui
andserver
objects, I'm not able to wrap theapp_ui
function (generated with {golem}) ingoogleAuthR::gar_shiny_ui()
when callingshinyApp()
.Steps to reproduce the problem
Below a simplified reproducible example of
app_ui
andapp_server
functions as created bygolem::create_golem()
:Expected output
App running.
Actual output
Session Info