如何在不使用服务帐户用户输入的情况下使用Bigrquery在Google Big Query中进行身份验证 [英] How to authenticate in Google Big Query using Bigrquery without user input using a service account

查看:85
本文介绍了如何在不使用服务帐户用户输入的情况下使用Bigrquery在Google Big Query中进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用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中进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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