问题描述
我正在使用已导出的 gargle 令牌,该令牌已导出到 RDS 文件。我目前无法检索另一个令牌,目前我只有这些。所以我不能以另一种更正确的方式导出它。
我使用此令牌通过 httr 连接到 Google My Business REST API。
使用令牌并为我访问数据的示例方法是:
token <- readRDS("/token/location/token.rds")
try(accounts <- invisible(GET("https://mybusiness.googleapis.com/v4/accounts",config(token = token)) %>%
httr::content(as = 'parsed')))
这将导致错误:
Auto-refreshing stale OAuth token.
Error in gzfile(file,mode) : cannot open the connection
In addition: Warning message:
In gzfile(file,mode) :
cannot open compressed file '[I have removed this sensitive data]',probable reason 'No such file or directory'
但是在下一次尝试中令牌将起作用,并且 httr::GET 将返回预期值。
我认为这是由具有预定义有效期的令牌引起的,并且在过期后需要更新。但是,在某些情况下(经过长时间计算)我无法预测令牌是否会过期。此外,每次在正确请求之前发出 GET 请求并不是一个好的解决方案,因为我会发出很多请求。
令牌对象本身包含以下结构:
> str(token)
Classes 'Gargle2.0','Token2.0','Token','R6' <Gargle2.0>
Inherits from: <Token2.0>
Public:
app: oauth_app
cache: function ()
cache_path: [I have removed this sensitive data]
can_refresh: function ()
clone: function (deep = FALSE)
credentials: list
email: [I have removed this sensitive data]
endpoint: oauth_endpoint
hash: function ()
init_credentials: function ()
initialize: function (email = gargle_oauth_email(),app = gargle_app(),package = "gargle",load_from_cache: function ()
package: googleAuthR
params: list
print: function (...)
private_key: NULL
refresh: function ()
revoke: function ()
sign: function (method,url)
validate: function ()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)