【问题标题】:How to setup Service accounts in Dataflow jobs如何在 Dataflow 作业中设置服务帐号
【发布时间】:2018-06-27 14:46:14
【问题描述】:

需要在 Dataflow 程序中设置服务帐户,从订阅者那里提取消息并对数据进行转换,最后存储在 BigQuery 表中。

方法:

GoogleCredential credentials = GoogleCredential.fromStream(new FileInputStream("credentials.json")).createScoped(Collections.singleton(??));

找不到正确的范围。感谢您对代码和使用凭据设置调用 Dataflow 作业的帮助。

【问题讨论】:

  • 有什么建议吗?

标签: google-cloud-dataflow


【解决方案1】:

这是触发从 Java API 到 GCP 平台的数据流作业的代码。

范围代码:

final List<String> SCOPES = Arrays.asList(
        "https://www.googleapis.com/auth/cloud-platform",
          "https://www.googleapis.com/auth/devstorage.full_control",
          "https://www.googleapis.com/auth/userinfo.email",
          "https://www.googleapis.com/auth/datastore",
          "https://www.googleapis.com/auth/pubsub");

DataflowpipelineOptions 代码:

options.setGcpCredential(ServiceAccountCredentials.fromStream(
                    new FileInputStream("abc.json")).createScoped(SCOPES));

【讨论】:

  • 是否可以将范围添加到默认凭据?
【解决方案2】:

不确定您要从哪里提取数据,但这里是 Google 产品的可用范围列表https://developers.google.com/identity/protocols/googlescopes

【讨论】:

  • 尝试在数据流作业中拉取消息,即使用 java 代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多