Gargle 非交互式服务帐户令牌身份验证不起作用

问题描述

我正在使用 googlesheets4 包,它使用 gargle 进行身份验证。我有一个定期运行的预定脚本,所以我需要设置非交互式身份验证。我尝试按照我找到的所有说明设置服务帐户令牌并使用它进行身份验证,但似乎仍然无法使其正常工作。

我创建了一个服务帐户令牌并将其存储在一个 JSON 文件中。然后我使用了以下命令:

gs4_auth (
   scopes="https://www.googleapis.com/auth/spreadsheets",path="/path/to/my/service/token.json")

使用 options(gargle_quiet = FALSE),我看到以下内容:

trying token_fetch()
trying credentials_service_account()
adding 'userinfo.email' scope
service account email: [email protected]

似乎一切正常!

但是当我尝试运行 gs <- gs4_find(my_sheet_name) 时,我得到以下信息:

attempt from: googledrive
trying token_fetch()
trying credentials_service_account()
Error: Argument 'txt' must be a JSON string,URL or file.
trying credentials_app_default()
trying credentials_gce()
trying credentials_byo_oauth()
Error: inherits(token,"Token2.0") is not TRUE
trying credentials_user_oauth2()
Gargle2.0 initialize
attempt from: googledrive
adding 'userinfo.email' scope
loading token from the cache
no matching token in the cache
initiating new token

...然后它会打开一个浏览器窗口,要求我登录我的帐户。 似乎 credentials_service_account() 第一次成功,但随后再次调用并失败。我在这里错过了什么?

提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)