I'm at a loss, I cannot figure out how to get non-interactive authorization working from the vignette found here. To me it seems it should be as simple as passing the path to the service account json file to gs4_auth()
, and this does work in R-Studio, but fails with shiny
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: [email protected]
#attempt from: googledrive
#trying token_fetch()
#trying credentials_service_account()
#Error: Argument 'txt' must be a JSON string, URL or file.
I've tried to figure out that error, everything I've read says it has something to do with fromJSON()
which token_fetch()
calls...but when I run that file path with fromJSON()
I have no issue.