问题描述
我需要使用Windows任务计划程序运行R脚本,但是该脚本包括使用Bigrquery对Big Query的身份验证.我具有服务帐户身份验证.当我运行脚本时,系统会要求用户输入,这不允许我按计划运行脚本.我得到:
I need to run an R script using windows task scheduler, however the script includes an authentication to Big Query using Bigrquery. I have the service account authentication. When I run the script I'm asked for user input which doesn't let me run the script as scheduled. I get:
The bigrquery package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token. Press
Esc/Ctrl + C to abort
1. ("Account I've used to authenticate")
这是我的代码:
library(googleAuthR)
library(bigrquery)
scopes = c("https://www.googleapis.com/auth/bigquery")
options(googleAuthR.scopes.selected = scopes)
service_token <- gar_auth_service(json_file="somejason.json")
gar_auth_service("somejason.json")
projectid<-'project_id'
datasetid<-'id'
bq_conn <- dbConnect(bigquery(),
project = projectid,
dataset = datasetid,
use_legacy_sql = FALSE
)
tables_list <- dbListTables(bq_conn)
The bigrquery package is requesting access to your Google account. Select
a pre-authorised account or enter '0' to obtain a new token. Press
Esc/Ctrl + C to abort.
1: ("Account I've used to authenticate")
是否有一种无需用户输入即可通过服务帐户进行身份验证的方法?
Is there a way to authenticate with the service account without needing user input?
推荐答案
所以我读了.
建议使用set_service_token(path ='somejson.json'),但已对其进行了描述.相反,我使用了bq_auth(path ='somejson.json').
There set_service_token(path='somejson.json') is suggested, but it's depricated. Instead, I used bq_auth(path='somejson.json').
这篇关于如何在不使用服务帐户用户输入的情况下使用Bigrquery在Google Big Query中进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!