0

我很茫然,我无法弄清楚如何从这里找到的小插图中获得非交互式授权。对我来说,它似乎应该像将服务帐户 json 文件的路径传递给一样简单gs4_auth(),这在 R-Studio 中确实有效,但因闪亮而失败


library(shiny)
library(DT)
library(tidyverse)
library(lubridate)
library(gargle)
library(googlesheets4)
options(gargle_quiet = FALSE)


# Define UI for application that draws a histogram
ui <- fluidPage(
    titlePanel("Mapper Tracker"),
    DTOutput("trackerTable")
)

# Define server logic required to draw a histogram
server <- function(input, output) {
    
    output$trackerTable <- renderDT({
    
        
        gs4_auth(path = "static-bond-283413-a1eef3c0351d.json")
        
        ss <- gs4_find("mapper_tracker")[[2]]
   
        for(i in 1:10){
            try({
                activity_sheet <- read_sheet(ss,sheet=1)
                hours_sheet <- read_sheet(ss,sheet=2)
                break
            },silent=FALSE)
        }
        
        datatable(hours_sheet,editable="row")
        
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

# Get this output from gargle:

#trying token_fetch()
#trying credentials_service_account()
#adding 'userinfo.email' scope
#service account email: mapper-tracker@static-bond-283413.iam.gserviceaccount.com
#attempt from: googledrive
#trying token_fetch()
#trying credentials_service_account()
#Error: Argument 'txt' must be a JSON string, URL or file.

我试图找出那个错误,我读过的所有内容都说它与fromJSON()调用有关token_fetch()......但是当我运行该文件路径时fromJSON()我没有问题。

4

0 回答 0