java如何对com进行身份验证。谷歌。云bigquery。带有服务帐户的BigQuery`
我想用这个图书馆
com.google.cloud.bigquery.BigQuery
如示例所示:
https://cloud.google.com/bigquery/create-simple-app-api
但是,我想用服务帐户验证BigQuery
客户机
我该怎么做
我只看到默认的凭证方式
BigQuery bigquery =
new BigQueryOptions.DefaultBigqueryFactory().create(BigQueryOptions.defaultInstance());
# 1 楼答案
请注意,根据Issue #3535,项目ID可能无法由
setCredentials
单独正确设置(“缺少项目ID”错误),因此应使用setProjectId
显式设置例如
# 2 楼答案
尝试使用setCredentials和ServiceAccountCredentials。在构建服务时使用fromStream
这应该更好地记录在谷歌的API文档中
希望有帮助,这是我关于stackoverflow的第一个答案:-)