我实际使用了 Google Cloud Platform 中服务帐户私钥的哪一部分? [英] Which part of the private key for service accounts in Google Cloud Platform do I actually use?

查看:20
本文介绍了我实际使用了 Google Cloud Platform 中服务帐户私钥的哪一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证我的 private_key 是否正确,如 这个问题.

I am trying to verify I have the private_key correct as described in this SO question.

有关服务帐户私钥的文档在这里.

{
"type": "service_account",
"project_id": "[PROJECT-ID]",
"private_key_id": "[KEY-ID]",
"private_key": "-----BEGIN PRIVATE KEY-----
[PRIVATE-KEY]
-----END PRIVATE KEY-----
",
"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]"
}

当使用 private_key 时,我是否只是获取了

When using private_key, do I just get the part in between the

-----BEGIN PRIVATE KEY-----

字符串和


-----END PRIVATE KEY-----

也就是说,示例中显示的[PRIVATE-KEY]?

In other words, the [PRIVATE-KEY] shown in the example?

或者我是否得到整个字符串,包括上面显示的两个书挡"字符串?

Or do I get the entire string including the two "bookend" strings shown above?

此外,在 [PRIVATE-KEY] 字符串中,出现了多次 子字符串.我是删除它们还是将它们留在里面?

Also, within the [PRIVATE-KEY] string, there are several occurrences of the 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.

  1. 验证 JSON 文件是为您的服务帐户生成的文件
  2. 验证是否正确读取了 JSON 文件.
  3. 确认您使用的是正确的 Firebase 方法

结论:

这个 Firebase 身份验证问题是由 JSON 读取故障引起的.

Conclusion:

This issue with Firebase authentication was caused by a malfunctioning JSON reading.

需要注意的是,私钥旨在与无用"密钥一起使用.信息,因为解码方法私钥期望这些字符串在那里.

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.

问题在于正确读取 JSON 文件.

The problem was reading the JSON file correctly.

感谢 @Tanaike@Tedinoz 了解故障排除步骤.

Thanks to @Tanaike and @Tedinoz for the troubleshooting steps.

这篇关于我实际使用了 Google Cloud Platform 中服务帐户私钥的哪一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆