授权从服务器上的R会话访问BigQuery [英] Authorization for accessing BigQuery from R session on server

查看:78
本文介绍了授权从服务器上的R会话访问BigQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用R和包bigrquery从R会话访问Bigquery。
只要我在本地机器上,这个工作就很棒。
然而,当我尝试在远程服务器上从R访问Bigquery时,它根本无法工作。



我试图复制.httr-oauth文件进入我的服务器上的主目录,但这不起作用。
我收到错误消息:

自动刷新陈旧的OAuth令牌。
在refresh_oauth2.0错误(self $ endpoint,self $ app,self $ credentials):
客户端错误:(400)错误请求


我真的不知道在哪里存储必要的证书,但不幸的是,我无法通过谷歌搜索该主题找到任何有用的信息。

解决方案

默认情况下,httr由bigrquery用于oauth,它将查看R会话的当前工作目录中的.httr-oauth。你可以用下面的方法覆盖这个位置(如果你愿意,可以把它放在你的.Rprofile中):

  options(httr_oauth_cache =〜/ .httr-oauth)

但是对于收到的错误消息,它看起来像位置不是问题,只需重新启动远程服务器上的oauth流以缓存新证书就可能更容易。要在远程服务器上触发新的oauth流程,请执行以下操作:
$ b


  1. 确保.httr-oauth文件不存在

  2. 重新启动R

  3. 使用bigrquery执行一个查询

请注意,如果httr尝试重定向到本地主机,您可以强制它执行out-of-band oauth流程:

  options(httr_oob_default = TRUE )


I am using R and package bigrquery to access Bigquery from an R session. This works great as long as I am on my local machine. However, when I try to access Bigquery from R on a remote server it does not work at all.

I tried to copy the .httr-oauth file into my home directory on the server but this does not work. I get the error message:

Auto-refreshing stale OAuth token. Error in refresh_oauth2.0(self$endpoint, self$app, self$credentials) : client error: (400) Bad Request

I really have no idea about where to store the necessary credentials and unfortunately I was not able to find anything useful about that by google-searching the topic.

解决方案

By default httr, which is used by bigrquery for oauth, will look in the R session's current working directory for .httr-oauth. You can override this location with the following (perhaps putting it in your .Rprofile if you like):

options("httr_oauth_cache"="~/.httr-oauth")

But for error message you received, its seems like the location is not the issue and it might be easier to just redo the oauth flow on the remote server to cache a new credential. To trigger a new oauth flow on the remote server:

  1. ensure the .httr-oauth file does not exist
  2. restart R
  3. perform one query with bigrquery

Note that if httr tries to redirect to localhost, you can force it to do an out-of-band oauth flow with:

options(httr_oob_default = TRUE)

这篇关于授权从服务器上的R会话访问BigQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆