auth0 Tutorial

The goal of {auth0} is to implement an authentication scheme to Shiny using OAuth Apps through the freemium service Auth0.

To create your authenticated shiny app, you need to follow the steps below. The full decription can be found in the README of the package site.

Create an Auth0 account and application

Configure your application

Now, let’s go to R!

Fill the _auth0.yml file


You can set the directory where this file will be created using the path= parameter. See ?auth0::use_auth0 for details. Your _auth0.yml file should be like this:

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

Run usethis::edit_r_environ() and add these three environment variables:


There’s how you identify each of them (see the image below):AUTH0_USER is your username, which can be found on the top corner of the site. AUTH0_KEY is your Client ID, which can be copied from inside the app page. AUTH0_SECRET is your Client Secret, which can be copied from the app page.

You can find more information about environment variables here. You can also fill these information directly in the _auth0.yml file (see below). If you do so, don’t forget to save the _auth0.yml file after editing it.

Create your app

Write a simple shiny app in a app.R file, like this:


ui <- fluidPage(
server <- function(input, output, session) {
  output$plot <- renderPlot({

# note that here we're using a different version of shinyApp!
auth0::shinyAppAuth0(ui, server)

Note: If you want to use a different path to the auth0 configuration file, you can either pass it to shinyAppAuth0() or set the auth0_config_file option by running options(auth0_config_file = "path/to/file").


You can try your app running

options(shiny.port = 8080)

If everything is OK, you should be forwarded to a login page and, after logging in or signing up, you’ll be redirected to your app.