简体   繁体   English

google oauth2 如何获取服务帐户的私钥

[英]google oauth2 how to get private key for service account

Can somebody please tell me how do I download the certificate from google cloud console for the service account.有人可以告诉我如何从谷歌云控制台下载服务帐户的证书。 I being searching all over the place.我正在到处寻找。 I have downloaded the applications authorization credential "client_secret.json"我已经下载了应用程序授权凭证“client_secret.json”

The client_secret.json has a key "client_x509_cert_url" key which takes me to the json file which has 2 certificates embedded in it. client_secret.json 有一个密钥“client_x509_cert_url”,它将我带到 json 文件,其中嵌入了 2 个证书。 Are this the certificate?这是证书吗? if they are how do I use it in java code.如果他们是我如何在java代码中使用它。 I am bit lost over here.我有点迷失在这里。

Update (2013-12-18): Google updated the Cloud Console this morning.更新 (2013-12-18):谷歌今天早上更新了 Cloud Console。 The new instructions for generating a private key are:生成私钥的新指令是:

  1. Open your project.打开您的项目。
  2. Go to "APIs & Auth".转到“API 和身份验证”。
  3. Go to "Credentials".转到“凭据”。
  4. Click "Create new client ID".单击“创建新的客户端 ID”。
  5. Select "Service Account".选择“服务帐户”。

Obsolete instructions (prior to 2013-12-18): Here is how to generate a private key in the Google Cloud Console:过时说明(2013-12-18 之前):以下是在 Google Cloud Console 中生成私钥的方法:

  1. Open your project.打开您的项目。
  2. Go to "APIs & Auth".转到“API 和身份验证”。
  3. Go to "Registered apps".转到“已注册的应用程序”。
  4. Click "Register app".点击“注册应用程序”。
  5. Select "Web application".选择“Web 应用程序”。
  6. Open "Certificate".打开“证书”。
  7. Click "Generate Certificate".单击“生成证书”。
  8. Click "Download Private Key".点击“下载私钥”。
  9. Click "View Public Key" to dismiss the dialog.单击“查看公钥”以关闭对话框。

The URL in the JSON instead takes you to a public URL where the public key for corresponding private key can be found - that's not what you are looking for. JSON 中的 URL 会将您带到一个公共 URL,在该 URL 中可以找到相应私钥的公钥 - 这不是您要查找的内容。

Open your project in gcloud在 gcloud 中打开您的项目

Go to "APIs & Services"转到“API 和服务”

Go to "Credentials".转到“凭据”。

Click "Create new client ID" or go to Service account if already created.单击“创建新客户 ID”或转到服务帐户(如果已创建)。

Select "Service Account".选择“服务帐户”。

Go to "Keys" and select "Create new key" from "ADD KEY" drop down转到“密钥”并从“添加密钥”下拉列表中选择“创建新密钥”

Select JSON or P12 as needed根据需要选择 JSON 或 P12

private_key is something like private_key 就像

"-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCxrDY54c6zXbPl\n47hElulfTBHWbI/03n/3ZwVhuaVnips11KyDImSdUH\n-----END PRIVATE KEY-----\n

should I remove "\\n" before using it?我应该在使用前删除“\\n”吗? Right now, I'm trying to sign the UTF-8 representation of the input using SHA256withRSA accordingly this document https://developers.google.com/identity/protocols/oauth2/service-account#httprest现在,我正在尝试使用 SHA256withRSA 对输入的 UTF-8 表示形式进行签名,相应地此文档https://developers.google.com/identity/protocols/oauth2/service-account#httprest

Please correct me if there is anything wrong with the answer here JWT Computing the Signature SHA256withRSA如果这里的答案有任何问题,请纠正我JWT Computing the Signature SHA256withRSA

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

相关问题 如何使用oauth2服务帐号获取登录用户的电子邮件? - How to get the email of the logged user with oauth2 service account? 带有Google Speech API RPC服务帐户的Google Oauth2无法正常工作 - Google Oauth2 with Service account for Google Speech API rpc not working google oauth2使用user@gmail.com模拟服务帐户 - google oauth2 impersonate service account with user@gmail.com 使用服务帐户对 Gmail 进行 OAuth2 身份验证 - Use service account for OAuth2 authentication to gmail Java中的Adwords API,OAuth2和服务帐户 - Adwords API, OAuth2 and service account in Java Spring Boot + Google OAuth2:如何定义用户详细信息服务? - Spring Boot + Google OAuth2: how to define user details service? 如何为电子表格服务设置OAuth2 Google凭据? - How do I set OAuth2 Google Credentials for Spreadsheet Service? 如何使用 Google Account Credential OAuth2 (Java) 从 Google 注销 - How to logout from Google using Google Account Credential OAuth2 (Java) 如何开始使用OAuth2 for Google Contacts API - How to get started with OAuth2 for Google Contacts API 无法使用Google API [google-oauth-java-client-1.12.0-beta]获取服务帐户流的令牌 - Unable to get token using Google APIs [google-oauth-java-client-1.12.0-beta] for service account flow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM