[英]Can't get Google Cloud Platform to recognize JSON service account key file. Error: PyOpenSSL is not available. Suggests JSON but I'm using a JSON key
I'm an utter newbie so forgive what may be a stupid question, but when I am trying to pass the location of my service account key file using Google Cloud Platform, I am receiving the message:我是一个完全的新手所以请原谅这个愚蠢的问题,但是当我尝试使用 Google Cloud Platform 传递我的服务帐户密钥文件的位置时,我收到了消息:
WARNING: .p12 service account keys are not recomended unless it is necessary for
backwards compatability. Please switch to a newer .json service account key for
this account.
ERROR: (gcloud.auth.activate-service-account) PyOpenSSL is not available. If you
have already installed PyOpenSSL, you will need to enable site packages by sett
ing the environment variable CLOUDSDK_PYTHON_SITEPACKAGES to 1. If that does not
work, see https://developers.google.com/cloud/sdk/crypto for details or consider using .json private key instead.
However I selected and downloaded a JSON key.但是我选择并下载了一个 JSON 密钥。 Can anyone tell me what is happening and how to get around this?
谁能告诉我发生了什么以及如何解决这个问题? Not sure if I'm providing enough info so please ask if you need details.
不确定我是否提供了足够的信息,所以请询问您是否需要详细信息。 Thanks!
谢谢!
The error indicates that you're possibly using a deprecated p12
format service account key file (as well as unable to find the required crypto libraries for reading keys in that format) instead of the json
format.该错误表明您可能正在使用已弃用的
p12
格式服务帐户密钥文件(以及无法找到读取该格式密钥所需的加密库)而不是json
格式。
You might want to double confirm that the key file you downloaded is indeed JSON.您可能需要再次确认您下载的密钥文件确实是 JSON。 A quick way to verify this is by opening this file in some text editor of if you're on
*nix
or OS X
, you can just use cat
.验证这一点的一种快速方法是在某些文本编辑器中打开此文件,如果您使用的是
*nix
或OS X
,则可以只使用cat
。 I've shown an example json service account key file:我展示了一个示例 json 服务帐户密钥文件:
$ cat my-service-account-key.json
{
"type": "service_account",
"project_id": "PROJECT_NAME",
"private_key_id": "YOUR_PRIVATE_KEY_ID",
"private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n",
"client_email": "SERVICE_ACCOUNT_NAME@PROJECT_NAME.iam.gserviceaccount.com",
"client_id": "CLIENT_ID",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "URL",
}
To activate the service account you will have to run the gcloud auth activate-service-account
command:要激活服务帐户,您必须运行
gcloud auth activate-service-account
命令:
gcloud auth activate-service-account --key-file=/path/to/service-account-key.json
The key must be encoded based on base64, you can do it with the following bash command:
密钥必须基于 base64 编码,您可以使用以下 bash 命令进行编码:
$ cat key_file.json | base64
Please take a look at gcloud setup instructions at: https://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud#inputs
请查看 gcloud 设置说明: https ://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud#inputs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.