我正在尝试自动运行一个 r 脚本以每小时下载一个私人 Google 表格。当我以交互方式使用 R 时,它总是可以正常工作。在我使用launchd
.
在我开始使用launchd
. 我认为问题在于一小时后访问令牌发生了变化,并且非交互式版本没有等待 OAuth 令牌的自动刷新。这是我从错误报告中得到的错误:
自动刷新陈旧的 OAuth 令牌。gzfile(file, mode) 中的错误:无法打开连接调用:gs_auth ... -> -> cache_token -> saveRDS -> gzfile 另外:警告消息:在 gzfile(file, mode) 中:无法打开压缩文件'。 httr-oauth',可能的原因'权限被拒绝'执行停止
我正在使用 Jenny Bryan 的 googlesheets 包。这是我最初用于注册工作表的代码,然后保存 oAuth 令牌:
gToken <- gs_auth() # Run this the first time to get the oAuth information
saveRDS(gToken, "/Users/…/gToken.rds") # Save the oAuth information for non-interactive use
然后我在我自动化的文件中使用以下脚本launchd
:
gs_auth(token = "/Users/…/gToken.rds")
使用自动运行脚本时如何避免此错误launchd
?