9

I'm trying to figure out what would be the method to automatically allow the googlesheet4 package to choose my pre - authorized account to download a particular google sheet.

For example - I want to run the following once a day -

library(googlesheets4)
delta<-read_sheet(
  "https://docs.google.com/spreadsheets/xyz...",
  sheet = "XYZ Delta"
)

The console gives the following output:

The googlesheets4 package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token. 
Press Esc/Ctrl + C to abort.

1. xyz@gmail.com

As can be seen above, I've already given it access to the account to utilize the google sheet in a previous step. But it still asks me to manually enter "1" to choose this account. Is it possible to automate this so I don't have to manually enter "1" to run this script when I autoschedule this code?

Would be grateful if you could point me to the right direction!

zx8754
  • 52,746
  • 12
  • 114
  • 209
sky_megh
  • 135
  • 6

1 Answers1

15

Call gs4_auth before read_sheet

gs4_auth("xyz@gmail.com")
Paul
  • 8,734
  • 1
  • 26
  • 36