如何解决Python get_iam_policies PUBSUB
我正在尝试运行此代码并收到此错误...我知道该如何解决?
from google.cloud import pubsub_v1
topic_id = 'start-instance-event'
client = pubsub_v1.PublisherClient(credentials=credentials)
topic_path = client.topic_path(project_id,topic_id)
policy = client.get_iam_policy(request={"resource": topic_path})
print("Policy for topic {}:".format(topic_path))
for binding in policy.bindings:
print("Role: {},Members: {}".format(binding.role,binding.members))
错误:
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "User not authorized to perform this action."
debug_error_string = "{"created":"@1604588362.110000000","description":"Error received from peer ipv6:[2a00:1450:4007:816::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1062,"grpc_message":"User not authorized to perform this action.","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
PermissionDenied Traceback (most recent call last)
解决方法
由于错误权限,似乎这与权限问题有关。在运行代码之前,您应该尝试Setting up authentication。在此documentation中,您将找到如何通过IAM API控制访问。
Task<Record[][]> task1 = GroupByKeyExcludingSomeGroups(subject);
source.ToObservable().Subscribe(subject); // This line does all the work
Record[][] result1 = task1.Result;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。