Currently, i am working on a Shiny web application. For data collection purpose I need direct access to google excel sheet instead of uploading a file into my application . How can i do that ?
something along the lines of this in your app code:-
library(googlesheets) # to setup googlesheet auth (comment out once done) ----------------------------------- #shiny_token <- gs_auth() # authenticate w/ your desired Google identity here #saveRDS(shiny_token, "shiny_app_token.rds") googlesheets::gs_auth(token = "shiny_app_token.rds") sheet_key <- "your_google_sheet_key_here" df <- googlesheets::gs_key(sheet_key) %>% gs_read_csv(ws = "worksheet_to_read")
shiny_app_directory.rds in the shiny app parent directory and be sure not to upload it to github!
Hi, to add to @paul 's comments, passing the
gs_auth() function will run you through obtaining the token, that then is saved in your working directory as a file named
.httr-oauth . The file is automatically added to your
.gitignore, so it’s not uploaded to your repo, I always double check for my sanity though.