2

I have been working on a shiny app that uses a google login which works perfect locally but as soon as I deploy it on shinyapps.io I get the error:

An error has occurred

Unable to connect to worker after 60.00 seconds; startup took too long.

library(shiny)
library(shinydashboard)
library(DT)
library(shinyWidgets)
library(shinyjs)
library(googlesheets4)
library(tidyverse)
library(googleAuthR)


options(googleAuthR.scopes.selected = c(
  "https://www.googleapis.com/auth/userinfo.email",
  "https://www.googleapis.com/auth/userinfo.profile"
))

options("googleAuthR.webapp.client_id" = "xxxxxxx")
options("googleAuthR.webapp.client_secret" = "xxxxxxxxxx")

get_email <- function() {
  f <- gar_api_generator(
    "https://openidconnect.googleapis.com/v1/userinfo",
    "POST",
    data_parse_function = function(x) x$email,
    checkTrailingSlash = FALSE
  )
  f()
}

ui <- navbarPage(
  title = "App Name",
  windowTitle = "Browser window title",
  tabPanel("Tab 1",
           useShinyjs(),
           sidebarLayout(
             sidebarPanel(
               p("Welcome!"),

               textOutput("display_username"),

               googleAuthUI("gauth_login")
             ),
             mainPanel(
              p("jabba")
             )
           )
  ),
  tabPanel("Tab 2",
           p("Layout for tab 2")
  )
)

server <- function(input, output, session) {
 
accessToken <- callModule(googleAuth, "gauth_login",
                            login_text = "Sign in via Google",
                            logout_text = "Sign Out",
                            login_class = "btn btn-success",
                            logout_class = "btn btn-success"
  )
  userDetails <- reactive({
    validate(
      need(accessToken(), "")
    )

    with_shiny(get_email, shiny_access_token = accessToken())
  })
  output$display_username <-
    renderText({
    if (is.null(accessToken()) == FALSE) {
      validate(
        need(userDetails(), ""))
      paste0("  ", userDetails())
  }
 })
}
runApp(list(ui = ui, server = server))

I created the credentials in Google Cloud platform and used the client id for web applications. Have given Authorised JavaScript origins as https://xxxx.shinyapps.io and Authorised redirect URI as https://xxxx.shinyapps.io/demo-app/

James Z
  • 12,209
  • 10
  • 24
  • 44

0 Answers0