【发布时间】:2019-10-27 11:41:12
【问题描述】:
我正在尝试使用 ServiceAccountCredentials.from_json() 对 Google Admin SDK 进行身份验证。我正在使用 Google Cloud Platform 来运行 Cloud Function。 Cloud Function 从 Cloud Storage 获取文件,对其进行解密,然后使用该文件对服务进行身份验证。根据this,我可以使用from_json_keyfile_name 进行身份验证。我不会有直接路径,所以我尝试使用来自Google Console -> API -> Download credentials 的文件内容进行身份验证。该 json 具有以下键:
- 类型
- project_id
- private_key_id
- private_key
- client_email
- client_id
- auth_uri
- token_uri
- auth_provider_x509_cert_url
- client_x509_cert_url
但是,ServiceAccountCredentials.from_json() 会查找 _private_key_pkcs12。这不在下载的 json 中。
【问题讨论】:
-
我无法理解问题所在以及您要完成的工作。您能否详细说明您遇到的问题是什么?
-
@Maxim 当然。基本上,我需要使用 json 为 Google Admin 创建一个服务帐户。不是 json 文件,而是实际的 json。
ServiceAccountCredentials.from_json()可以做到这一点,但它不包括像_private_key_pkcs12这样的数据,这些数据在从 Google 控制台下载的 json 文件中找不到。
标签: google-cloud-platform google-cloud-functions google-cloud-storage google-authentication service-accounts