简体   繁体   English

我实际使用 Google Cloud Platform 中服务帐户的私钥的哪一部分?

[英]Which part of the private key for service accounts in Google Cloud Platform do I actually use?

I am trying to verify I have the private_key correct as described in this SO question .我正在尝试验证我的private_key是否正确, 如此 SO question中所述。

Docs about service account private keys are here. 有关服务帐户私钥的文档在这里。

{
"type": "service_account",
"project_id": "[PROJECT-ID]",
"private_key_id": "[KEY-ID]",
"private_key": "-----BEGIN PRIVATE KEY-----\n[PRIVATE-KEY]\n-----END PRIVATE KEY-----\n",
"client_email": "[SERVICE-ACCOUNT-EMAIL]",
"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": "https://www.googleapis.com/robot/v1/metadata/x509/[SERVICE-ACCOUNT-EMAIL]"
}

When using private_key , do I just get the part in between the使用private_key时,我是否只是在

-----BEGIN PRIVATE KEY-----\n

string and the字符串和

\n-----END PRIVATE KEY-----\n

In other words, the [PRIVATE-KEY] shown in the example?换句话说,示例中显示的[PRIVATE-KEY]

Or do I get the entire string including the two "bookend" strings shown above?还是我得到整个字符串,包括上面显示的两个“书挡”字符串?

Also, within the [PRIVATE-KEY] string, there are several occurrences of the \n substring.此外,在[PRIVATE-KEY]字符串中,多次出现\n substring。 Do I remove them or leave them in?我是删除它们还是留下它们?

This question is also related to another question , so look out for similar symptoms when debugging.这个问题也和另一个问题有关,所以调试的时候要注意类似的症状。

Troubleshooting steps:故障排除步骤:

  1. Verify that the JSON file is the one generated for your service acocunt验证 JSON 文件是为您的服务帐户生成的文件
  2. Verify that the JSON file is being read properly.验证 JSON 文件是否被正确读取。
  3. Verify that you are using the correct Firebase methods验证您使用的是正确的 Firebase 方法

Conclusion:结论:

This issue with Firebase authentication was caused by a malfunctioning JSON reading. Firebase 身份验证的此问题是由 JSON 读取故障引起的。

It's important to note that the private keys are meant to be used with the "useless" information, since the method to decode the private key is expecting those strings to be there.重要的是要注意,私钥是用来与“无用”信息一起使用的,因为解码私钥的方法期望这些字符串存在。

TL;DR TL;博士

The problem was reading the JSON file correctly.问题是正确读取 JSON 文件。

Thanks to @Tanaike and @Tedinoz for the troubleshooting steps.感谢@Tanaike@Tedinoz的故障排除步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 一个项目在谷歌云平台中可以拥有的服务账户数量有上限吗? - Is there a maximum number of service accounts that a project can have in the google cloud platform? 我应该如何处理 Google AppEngine 中服务帐户的私钥文件? - How should I handle private key files in Google AppEngine for service accounts? 我的用例需要哪些Google Cloud产品? - Which Google Cloud products do I need for my use case? 哪个MBaaS平台用于特定项目:Parse或Google Cloud - Which MBaaS platform to use for a specific project: Parse or Google Cloud 如何在没有PEM编码的RSA私钥的Google Cloud Platform上设置SSL证书 - How to setup SSL certificate on Google Cloud Platform without PEM encoded RSA private key 我可以使用Google服务帐户来验证INCOMING请求吗? - Can I use google service accounts to authenticate INCOMING requests? 我应该在 Google Cloud Platform (PHP) 中使用什么数据库主机名 - What database hostname should I use in Google Cloud Platform (PHP) 我可以使用 Google Cloud Platform 来托管我的网站吗? - Can I use Google Cloud Platform to host my website? 如何在 Google Cloud Platform 的 DataStore 中存储值? - How do I store values in DataStore in Google Cloud Platform? Google云端平台:SERVICE_UNAVAILABLE问题 - Google Cloud Platform: SERVICE_UNAVAILABLE issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM