我实际使用Google Cloud Platform中服务帐户的私钥的哪一部分? [英] Which part of the private key for service accounts in Google Cloud Platform do I actually use?
问题描述
我正在尝试验证自己是否具有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-----\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]"
}
使用private_key
时,我是否只是将零件放在了
When using private_key
, do I just get the part in between the
-----BEGIN PRIVATE KEY-----\n
字符串和
\n-----END PRIVATE KEY-----\n
换句话说,示例中显示的[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]
字符串中,多次出现\n
子字符串.我要删除它们还是将它们留在里面?
Also, within the [PRIVATE-KEY]
string, there are several occurrences of the \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.
- 验证JSON文件是为您的服务acocunt生成的文件
- 验证已正确读取JSON文件.
- 验证您使用的是正确的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.