Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth_info null on shinyapps #72

Open
chintanp opened this issue Jun 1, 2020 · 6 comments
Open

auth_info null on shinyapps #72

chintanp opened this issue Jun 1, 2020 · 6 comments

Comments

@chintanp
Copy link

chintanp commented Jun 1, 2020

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.

@jtrecenti
Copy link
Member

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?

@chintanp
Copy link
Author

chintanp commented Jun 1, 2020

@jtrecenti I am using app.R. Is the code for your example app public somewhere?

@jtrecenti
Copy link
Member

jtrecenti commented Jun 1, 2020

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

@chintanp
Copy link
Author

chintanp commented Jun 1, 2020

@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")

@mxfeinberg
Copy link

@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.

@homer3018
Copy link

homer3018 commented Apr 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants