Reputation: 6979
I am trying to build a shiny app that needs to access my bigquery tables, it works fine locally through interactive authentication.
Whey I deploy the app it does not work giving the error:
Error: oauth_listener() needs an interactive environment.
There is a suggestion here - Authorization for accessing BigQuery from R session on server, but I don't know how to pass the .httr-oauth
file to shinyapps.io
Upvotes: 1
Views: 1874
Reputation: 6979
The way it was resolved is you need to generate access token json file in Google Cloud IAM with relevant access to BigQuery resources.
This file should be placed in your appDir
folder and referenced in code, e.g.:
with bigrquery
package
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)
, or with retl
package:
# 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)
Upvotes: 1