我有一个与 BigQuery 项目关联的 AppEngine 帐户,但是当我尝试运行查询时,我在响应中收到“拒绝访问”。我已经像这样设置了一个 AppIdentityCredential:
private static AppIdentityCredential getCredential() throws IOException, GeneralSecurityException {
return new AppIdentityCredential(BigqueryScopes.BIGQUERY);
}
public static Bigquery createAuthorizedClient() throws IOException, GeneralSecurityException {
return new Bigquery(TRANSPORT, JSON_FACTORY, getCredential());
}
我还尝试按照此处的指示使我的 AppEngine 帐户成为 BigQuery“团队”的成员:https://developers.google.com/bigquery/docs/authorization#service-accounts-appengine
但是,Google 的 API 控制台上的团队页面在我的 AppEngine 服务帐户名称旁边显示“已发送邀请。等待响应”。我没有收到邀请(超过 18 小时),尽管我是 AppEngine 和 BigQuery 双方的所有者和唯一的团队成员。这让我认为 BigQuery/AppEngine 服务集成刚刚被打破,但如果有人看到我做错了什么,我将非常感谢帮助。
最佳答案
我的猜测是您在控制台项目中的团队选项卡链接到应用引擎权限,也就是说,当您希望提供访问权限的邮件地址显示待处理时。
请尝试在启用 Bigquery API(可选 GS API)的情况下创建新的控制台项目。之后添加您的 appengine 服务帐户 (xxxxxx@appspot.gserviceaccount.com),并具有编辑权限。
希望有了它你一定能做你想做的事。
另请参阅 Michael Manoochehri 的帖子对于片段。
关于java - 无法从 AppEngine java 访问 BigQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15669749/