我正在尝试如下:public class App2 { public static void main(String[] args) { Pipeline pipeline = Pipeline.create(PipelineOptionsFactory.fromArgs(args).create()); pipeline .apply("ReadStrinsFromPubsub", PubsubIO.readStrings().fromTopic("projects/dev/topics/trading")) .apply("PrintToStdout", ParDo.of(new DoFn<String, Void>() { @ProcessElement public void processElement(ProcessContext c) { System.out.printf("Received at %s : %s\n", Instant.now(), c.element()); // debug log } })); pipeline.run().waitUntilFinish(); }}发生错误的原因是:com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden{ "code" : 403, "errors" : [ { "domain" : "global", "message" : "The request is missing a valid API key.", "reason" : "forbidden" } ], "message" : "The request is missing a valid API key.", "status" : "PERMISSION_DENIED"}我该如何解决?
2 回答
幕布斯7119047
TA贡献1794条经验 获得超8个赞
您可能缺少为本地计算机设置的用于访问 GCP 的服务帐户。
请参阅身份验证入门以设置您的服务帐户和 GOOGLE_APPLICATION_CREDENTIALS 变量。
1) 在 GCP 控制台中创建服务帐号;
2) 将json密钥文件下载到本地;
3)将GOOGLE_APPLICATION_CREDENTIALS变量设置为json密钥文件的路径。
添加回答
举报
0/150
提交
取消