Google 安全中心 Python API 失败
Google Security Center Python API Failing
我正在尝试使用 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
使用 Python 3.6,我在客户端创建了 json 密钥文件和我的组织 ID。知道为什么我无法让任何客户端功能正常工作吗?
I am passing the API Key in as the argument for authentication like this
client = securitycenter.SecurityCenterClient("gcp-sc.json")
如果您有一个名为 gcp-sc.json
的文件,其中包含 Google 凭证数据,
- 设置环境变量
GOOGLE_APPLICATION_CREDENTIALS
指向那个路径,然后在没有配置的情况下初始化客户端(SecurityCenterClient()
),它会选择
- 或者如果您需要明确命名文件,
SecurityCenterClient.from_service_account_json('gcp-sc.json')
应该可以解决问题。
您还可以将自定义凭据对象(参见 the docs)作为 SecurityCenterClient(credentials=...)
我正在尝试使用 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
使用 Python 3.6,我在客户端创建了 json 密钥文件和我的组织 ID。知道为什么我无法让任何客户端功能正常工作吗?
I am passing the API Key in as the argument for authentication like this
client = securitycenter.SecurityCenterClient("gcp-sc.json")
如果您有一个名为 gcp-sc.json
的文件,其中包含 Google 凭证数据,
- 设置环境变量
GOOGLE_APPLICATION_CREDENTIALS
指向那个路径,然后在没有配置的情况下初始化客户端(SecurityCenterClient()
),它会选择 - 或者如果您需要明确命名文件,
SecurityCenterClient.from_service_account_json('gcp-sc.json')
应该可以解决问题。
您还可以将自定义凭据对象(参见 the docs)作为 SecurityCenterClient(credentials=...)