0

我尝试允许用户在闪亮的应用程序中连接到谷歌分析帐户(使用闪亮代理):

library(shiny)
library("googleAnalyticsR")
options(googleAuthR.verbose=2)
ui <- fluidPage(
  actionButton(inputId = "go",label = "go"),
  verbatimTextOutput("log")
)

server <- function(input, output, session) {
  info <- reactiveValues()
  observeEvent(input$go,{
    message("clic")
    ga_auth(new_user = TRUE)
    info$account_list <- ga_account_list()
  })

  output$log <- renderPrint({
    print(info$account_list)
  })

}

shinyApp(ui, server)

此应用程序在交互式上下文中运行良好,但在使用 shinyproxy 部署时却没有出现此错误:

2018-08-31 21:01:34> No local token found in session
2018-08-31 21:01:34> Auto-refresh of token not possible, manual re-authentication required
Warning: Error in : Authentication options didn’t match existing session token and not interactive session
so unable to manually reauthenticate
78: stop
77: make_new_token
76: gar_auth
75: gar_auto_auth
74: ga_auth
73: observeEventHandler [/usr/local/lib/R/site-library/gauth/app/app.R#27]
2: shiny::runApp
1: gauth::run_app

我怎样才能允许用户登录到他的谷歌分析帐户?

我的工作在这里:https ://github.com/VincentGuyader/gauth

(Dockerfile、application.yml 和源代码)

问候

4

1 回答 1

0

该错误表明ga_auth()找不到现有的身份验证缓存文件,并且您处于非交互式会话中,因此无法创建新的。

您是否只连接到您自己的 Google Analytics(分析)帐户?

在这种情况下,最简单的方法是与您的应用一起上传您在ga_auth()本地使用时创建的离线身份验证令牌(称为.httr-oauthor ga.oauth),然后当您ga_auth()在 Shiny 应用程序中运行时,它将重用您的令牌。

您也可以在函数中专门指定令牌文件,例如ga_auth("ga.oauth")

如果您想要一个用户登录自己帐户的多用户帐户,则需要使用网站上记录的特定 Shiny 功能。

于 2018-09-03T09:24:36.957 回答