![](/img/trans.png)
[英]How can I get a Kubernetes clientset in GO using a JSON service account key?
[英]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
我是一个完全的新手所以请原谅这个愚蠢的问题,但是当我尝试使用 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.
但是我选择并下载了一个 JSON 密钥。 谁能告诉我发生了什么以及如何解决这个问题? 不确定我是否提供了足够的信息,所以请询问您是否需要详细信息。 谢谢!
该错误表明您可能正在使用已弃用的p12
格式服务帐户密钥文件(以及无法找到读取该格式密钥所需的加密库)而不是json
格式。
您可能需要再次确认您下载的密钥文件确实是 JSON。 验证这一点的一种快速方法是在某些文本编辑器中打开此文件,如果您使用的是*nix
或OS X
,则可以只使用cat
。 我展示了一个示例 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",
}
要激活服务帐户,您必须运行gcloud auth activate-service-account
命令:
gcloud auth activate-service-account --key-file=/path/to/service-account-key.json
密钥必须基于 base64 编码,您可以使用以下 bash 命令进行编码:
$ cat key_file.json | base64
请查看 gcloud 设置说明: https ://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud#inputs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.