【问题标题】:How to access bigquery from shiny app如何从闪亮的应用程序访问 bigquery
【发布时间】:2016-06-09 10:18:27
【问题描述】:

我正在尝试构建一个需要访问我的 bigquery 表的闪亮应用,它通过交互式身份验证在本地运行良好。

我部署的应用程序它不起作用并给出错误:

错误:oauth_listener() 需要交互式环境。

这里有一个建议-Authorization for accessing BigQuery from R session on server,但我不知道如何将.httr-oauth 文件传递​​给shinyapps.io

【问题讨论】:

  • ?deployApp 并注意 appFiles 参数。将凭证文件加载到您无法控制的服务器上时要格外小心。
  • 出现错误:The project should have one of the following layouts: 1. 'shiny.R' and 'ui.R' in the application base directory,.. appFiles 中应该包含什么内容?

标签: r google-bigquery shiny


【解决方案1】:

解决方法是您需要在 Google Cloud IAM 中生成访问令牌 json 文件,并具有对 BigQuery 资源的相关访问权限。

此文件应放在您的appDir 文件夹中并在代码中引用,例如:

带有bigrquery

library(bigrquery)
set_service_token('access_token.json')

tb <- bq_dataset_query(
   x = ds,
   query = sql,
   billing = '{your billing project}',
   use_legacy_sql = use.legacy.sql,
   parameters = params
)
dt <- bq_table_download(tb)

,或使用retl 包:

# set env var `BIGQUERY_ACCESS_TOKEN_PATH` to path of your token file.
devtools::install_github(madedotcom/retl)
library(retl)
library(data.table)
dt <- bqExecuteQuery(sql)

【讨论】:

    猜你喜欢
    • 2019-04-09
    • 1970-01-01
    • 2015-06-27
    • 2016-02-09
    • 1970-01-01
    • 2019-09-29
    • 2017-07-27
    • 2014-10-28
    • 2018-05-12
    相关资源
    最近更新 更多