【发布时间】:2016-11-25 17:45:52
【问题描述】:
我正在尝试自动运行 r 脚本以每小时下载一个私人 Google 表格。当我以交互方式使用 R 时,它总是可以正常工作。在我使用 launchd 自动执行脚本后的第一个小时内,它也可以正常工作。
在我开始使用 launchd 自动化它一小时后它停止工作。我认为问题在于一小时后访问令牌发生了变化,并且非交互式版本没有等待 OAuth 令牌的自动刷新。这是我从错误报告中得到的错误:
自动刷新陈旧的 OAuth 令牌。 gzfile(文件,模式)中的错误:无法打开连接 调用: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 自动运行脚本时如何避免此错误?
【问题讨论】:
标签: launchd r-googlesheets non-interactive