auth0
auth0 copied to clipboard
`auth_info` null on shinyapps
Authentication works fine, but when I try to use the value of session$userData$auth_info, it is NULL.
observeEvent(input$submitButton, {
# ulid_submit <- ulid::ULIDgenerate()
dt_submit <- Sys.time()
auth0_sub <- session$userData$auth0_info$sub
auth0_userid <-
strsplit(auth0_sub, "|", fixed = TRUE)[[1]][2]
user_name <- session$userData$auth0_info$name
user_email <- session$userData$auth0_info$email
...
This works locally. Is it possible that shinyapps has a different version of auth0 package or underlying API that makes the session$userData NULL.
Hi @chintanp, thanks for the issue.
My apps run with userinfo locally and in shinyapps.io, using the same configuration.
Working example (try to login with google): https://jubs.shinyapps.io/userinfo
Are you using app.R or ui.R/server.R paradigm?
@jtrecenti I am using app.R. Is the code for your example app public somewhere?
It's the example from the documentation. I've just added a logoutButton() and added https://jubs.shinyapps.io/userinfo to the remote_url: parameter in the .yml file.
https://curso-r.github.io/auth0/articles/examples/userinfo.html
@jtrecenti Thanks. So it seems that the way to get to auth_info is to call it in a reactive context, which I think I am doing.
My _auth0.yml file, in case I messed something up here:
name: myApp
remote_url: https://cp84.shinyapps.io/evi_des/
shiny_config: http://localhost:8100
auth0_config:
scope: "openid email profile"
api_url: !expr paste0('https://', Sys.getenv('AUTH0_USER'), '.auth0.com')
credentials:
key: !expr Sys.getenv("AUTH0_KEY")
secret: !expr Sys.getenv("AUTH0_SECRET")
@jtrecenti I'm able to reproduce the error explained here when I split the App.R file into ui.R and server.R files. Please look at the following example.
ui.R
auth0::auth0_ui(
ui <- shiny::fluidPage(
shiny::verbatimTextOutput("user_info")
)
)
server.R
auth0::auth0_server(
server <- function(input, output, session) {
# print user info
output$user_info <- shiny::renderPrint({
session$userData$auth0_info
})
}
)
Am I doing something wrong? Or should I just keep everything in one file? For reference, I'm using the _auth0.yml form you are using.
Hello.
I'm also experiencing this, even locally. I do use a server.R/ui.R paradigm.
One other thing is that I'm not sure I understand correctly how one should use the remote_url and shiny_config variables. At the moment I do not use shiny_config within my _auth0.yml.
Edit : scratch that. Made a mistake and it's working now.