Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Stackdriver Google Python API访问被拒绝_Python_Google Cloud Platform_Stackdriver_Google Python Api - Fatal编程技术网

Stackdriver Google Python API访问被拒绝

Stackdriver Google Python API访问被拒绝,python,google-cloud-platform,stackdriver,google-python-api,Python,Google Cloud Platform,Stackdriver,Google Python Api,尝试使用Google Cloud Python3 API客户端创建接收器时,出现以下错误: RetryError: GaxError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.PERMISSION_DENIED, The caller does not have

尝试使用Google Cloud Python3 API客户端创建接收器时,出现以下错误:

RetryError: GaxError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.PERMISSION_DENIED, The caller does not have permission)>)
我使用的代码是:

import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'path_to_json_secrets.json'

from google.cloud.bigquery.client import Client as bqClient
bqclient = bqClient()
ds = bqclient.dataset('dataset_name')

print(ds.access_grants)
[]

ds.delete()
ds.create()

print(ds.access_grants)
[<AccessGrant: role=WRITER, specialGroup=projectWriters>,
 <AccessGrant: role=OWNER, specialGroup=projectOwners>,
 <AccessGrant: role=OWNER, userByEmail=id_1@id_2.iam.gserviceaccount.com>,
 <AccessGrant: role=READER, specialGroup=projectReaders>]

from google.cloud.logging.client import Client as lClient
lclient = lClient()
dest = 'bigquery.googleapis.com%s' %(ds.path)
sink = lclient.sink('sink_test', filter_='jsonPayload.project=project_name', destination=dest)
sink.create()
我不太明白为什么会这样。当我使用lclient.log_struct时,我可以看到日志到达日志控制台,因此我可以访问Stackdriver日志

这个设置有错误吗


提前感谢。

创建接收器需要与写入日志项不同的权限。默认情况下,服务帐户被授予“项目编辑器”而不是“所有者”,后者没有创建接收器的权限

请参阅所需权限的列表

确保您使用的服务帐户具有logging.sinks.create权限。实现这一点的最简单方法是将服务帐户从编辑器切换到所有者,但最好添加日志编辑器角色,这样您就可以给它所需的权限