1

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: 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.

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.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Karl Johnson
  • 111
  • 1
  • 7
  • 1
    Had the same issue as you. Followed [these](https://stackoverflow.com/questions/44980757/remote-server-authentication-to-read-googlesheets-from-r-script-not-using-servic/59910070#59910070) directions and got it to work. – Chris K Jul 22 '20 at 22:51
  • @ChrisK I actually managed to find that not to long after posting and can confirm it worked for me also. If anyone else has this issue I would suggest that method...the thing with the service accounts must be a bug, hopefully the team working on it will fix soon – Karl Johnson Jul 23 '20 at 12:14

0 Answers0