我一直在开发一个使用谷歌登录的闪亮应用程序,该应用程序在本地完美运行,但一旦我将它部署到 shinyapps.io 上,我就会收到错误消息:
发生了错误
60.00 秒后无法连接到 worker;启动时间过长。
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))
我在 Google Cloud 平台中创建了凭据,并将客户端 ID 用于 Web 应用程序。已将授权的 JavaScript 来源作为https://xxxx.shinyapps.io和授权的重定向 URI 作为https://xxxx.shinyapps.io/demo-app/