安排代码时,如何在R中的googlesheets4中自动选择预授权帐户?

问题描述

我正在尝试找出一种自动允许googlesheet4软件包选择我的预授权帐户来下载特定Google表格的方法

例如-我想每天运行一次以下内容-

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

控制台提供以下输出

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

从上面可以看出,在上一步中,我已经授予它访问帐户的权限,以利用Google表格。但是它仍然要求我手动输入“ 1”来选择此帐户。 是否可以自动执行此操作,以便在我自动计划此代码时不必手动输入“ 1”来运行此脚本?

如果能为我指明正确的方向,将不胜感激!

解决方法

gs4_auth之前致电read_sheet

gs4_auth("xyz@gmail.com")