我正在尝试使用Python API从Google安全中心检索结果。我已经安装了python库,设置了一个服务帐户,生成了一个密钥,当我尝试获取查找或任何客户端函数时,我得到了以下错误:
Traceback (most recent call last):
File "./find.py", line 12, in <module>
finding_result_iterator = client.list_findings(all_sources)
File "/usr/local/lib/python3.6/site-packages/google/cloud/securitycenter_v1/gapic/security_center_client.py", line 1532, in list_findings
self.transport.list_findings,
AttributeError: 'str' object has no attribute 'list_findings'
我正在使用下面的代码示例: https://cloud.google.com/security-command-center/docs/how-to-api-list-findings
使用Python3.6,我在客户端创建中有json密钥文件和我的组织id。你知道为什么我不能让任何客户端函数工作吗
如果您有一个名为
gcp-sc.json
的文件,其中包含Google凭证数据,则GOOGLE_APPLICATION_CREDENTIALS
设置为指向该路径,然后在没有配置的情况下初始化客户机(SecurityCenterClient()
),它将拾取该路径SecurityCenterClient.from_service_account_json('gcp-sc.json')
应该这样做李>还可以将自定义凭据对象(请参见the docs)作为
SecurityCenterClient(credentials=...)
传入相关问题 更多 >
编程相关推荐