Hattie35
Hattie35

Reputation: 97

'Misconfiguration in the system' error in local R Shiny app connected to Auth0 using the Auth0 library

I am trying to create a simple shiny app that is connected to the Auth0 password system using the Auth0 library. Currently, I am just trying to run locally. I get an Auth0 page that says 'there could be a misconfiguration in the system or a service outage' when I try to run, but I can't figure out why. I took the following steps:

  1. library(Auth0) in app
  2. shinyServerAuth0(...) in app
  3. created a Auth0 'regular web application' project
  4. copied the Auth0 project secret, name, and username, and set it to variables in .Renviron
  5. added the URLS 'http://localhost:8080, https://[redacted].shinyapps.io/' to the Callback, Logout, and Web Origin settings.
  6. Saved/refreshed everything.

Any thoughts?

Upvotes: 1

Views: 3552

Answers (3)

Akash Agrawal
Akash Agrawal

Reputation: 1

I was also facing the same problem and getting the same error again and again whenever I tried to log in through it. But, now I find the solution and it works for me. Solution:

Currently, auth0 has changed their way to write the 'clientID' and 'domain' names, etc. Earlier, they were writing in the following way:

<Auth0Provider
    domain="dev-12334556767.us.auth0.com"
    clientId="abdgcfdhdfhjgjrbubrfubhbure"
    redirect_uri: window.location.origin
    >
    <AppProvider>
      <App />
    </AppProvider>
</Auth0Provider>

But, now things have changed now, and follow this below pattern to write the configuration of auth0:

<Auth0Provider
    domain="dev-12334556767.us.auth0.com"
    clientId="abdgcfdhdfhjgjrbubrfubhbure"
    authorizationParams={{
      redirect_uri: window.location.origin
    }}
  >
  <AppProvider>
    <App />
  </AppProvider>
</Auth0Provider>

I hope this will work for everyone. Thanks

Upvotes: 0

Mwavu
Mwavu

Reputation: 2227


Context

A similar problem that happened to have the same solution as @Hattie35's. I'm putting it here just in case someone else comes across it.

I was about to ask the question here on StackOverflow when @Hattie35's question popped up in the suggestions.

Here you go:



Problem

I'm trying to implement authentication to my R Shiny app using the {auth0} package.

I have followed the documentation step by step for around 10 times now but I keep getting the same error on my browser when I run the application:

Unknown host: thetechie.auth0.com

Nothing else shows on the page.

Has anyone else encountered this before? What might I be missing? I'd really appreciate any pointers in the right direction.



Reprex

app.R:

options(shiny.port = 8085)

library(shiny)

ui <- fluidPage(
  fluidRow(
    plotOutput("plot")
  )
)

server <- function(input, output, session) {
  output$plot <- renderPlot({
    plot(1:10)
  })
}

auth0::shinyAppAuth0(ui, server)

_auth0.yml:

name: myApp
remote_url: ''
auth0_config:
  api_url: !expr paste0('https://', Sys.getenv('AUTH0_USER'), '.auth0.com')
  credentials:
    key: !expr Sys.getenv("AUTH0_KEY")
    secret: !expr Sys.getenv("AUTH0_SECRET")

.Renviron:

AUTH0_USER=thetechie
AUTH0_KEY=ClientId
AUTH0_SECRET=ClientSecret

Allowed Callback URLs, Allowed Logout URLs and Allowed Web Origins are all:

http://localhost:8085/


Solution

As @Hattie35 suggested, edit the autogenerated _auth0.yml and add the region "part" to the api_url:

name: myApp
remote_url: ''
auth0_config:
  api_url: !expr paste0('https://', Sys.getenv('AUTH0_USER'), '.us.auth0.com')
  credentials:
    key: !expr Sys.getenv("AUTH0_KEY")
    secret: !expr Sys.getenv("AUTH0_SECRET")

Upvotes: 0

Hattie35
Hattie35

Reputation: 97

Update: I finally figured out what I was doing wrong. I was setting the api_url to be https://[my_name].auth0.com instead of https://[my_name].us.auth0.com. So if you use the autogenerated YML and the US url make sure to change that.

Upvotes: 2

Related Questions