执行 Stackdriver AsyncReporter 运行状况检查时出现 GCP 错误

问题描述 投票:0回答:2

尝试执行 Stackdriver AsyncReporter 运行状况检查时,我的应用程序运行时出现以下错误。我似乎无法从文档中找到需要哪些身份验证范围。

io.grpc.StatusRuntimeException: PERMISSION_DENIED: The caller does not have permission
    at io.grpc.Status.asRuntimeException(Status.java:535)
    at zipkin2.reporter.stackdriver.internal.AwaitableUnaryClientCallListener.onClose(AwaitableUnaryClientCallListener.java:100)
    at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:463)
    at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:427)
    at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:460)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
    at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

目前,我的应用程序正在使用以下身份验证范围

Scopes in use by default credentials: 

[https://www.googleapis.com/auth/pubsub,
 https://www.googleapis.com/auth/spanner.admin,
 https://www.googleapis.com/auth/spanner.data, 
 https://www.googleapis.com/auth/datastore, 
 https://www.googleapis.com/auth/sqlservice.admin, 
 https://www.googleapis.com/auth/devstorage.read_only, 
 https://www.googleapis.com/auth/devstorage.read_write, 
 https://www.googleapis.com/auth/cloudruntimeconfig, 
 https://www.googleapis.com/auth/trace.append,
 https://www.googleapis.com/auth/cloud-platform,
 https://www.googleapis.com/auth/cloud-vision, 
 https://www.googleapis.com/auth/bigquery,
 https://www.googleapis.com/auth/monitoring.write]
google-cloud-platform google-oauth stackdriver google-cloud-stackdriver
2个回答
0
投票

服务帐号调用api所需的前提是

  1. 选择或创建云平台项目。
  2. 启用 StackdriverLogging API。
  3. 使用服务帐户设置身份验证,以便您可以 访问 API。
  4. 检查您的服务帐号是否允许创建。

Stackdriver Logging API 禁止仅使用 API 密钥发出请求,并要求对请求进行身份验证 (OAuth2)。必须向请求用户授予所需的Cloud IAM 权限。由于它们通常访问或修改受 IAM 保护的资源,因此大多数 Google Cloud API 都以这种方式运行。此外,如果请求仅使用 API 密钥,则没有“主体”可以授予访问权限。

附上支持doc供您参考。


0
投票

我遇到了同样的问题,解决方案是添加

Cloud Trace API
向用于运行应用程序的服务帐户写入权限(在我的例子中是云运行)。

© www.soinside.com 2019 - 2024. All rights reserved.