How can i receive directly google excel sheet data in R shiny application

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 ?

Hi, I've never used it, but I think the googlesheets package might be helpful :slight_smile:


something along the lines of this in your app code:-


# 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") 

Store the shiny_app_directory.rds in the shiny app parent directory and be sure not to upload it to github!

1 Like

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.

1 Like