google-chrome - 您在哪里可以找到或如何创建 chrome 扩展 key 并将其放置在您的 manifest.json 文件中?

标签 google-chrome google-chrome-extension oauth-2.0 manifest.json

希望在我的 Chrome 扩展中实现 Oauth2
我一直在研究如何在 chrome 扩展上实现 oauth2。我已经被困了很长一段时间。我最终得到了在我的 background.ts 文件中使用 chrome.identity 的信息。
这是我的 manifest.json

...
"permissions": [
    "identity"
],
"oauth2": {
    "client_id": "855289137547-bd37ghe68neqevqs47esitvc99rb5f8d.apps.googleusercontent.com",
    "scopes":["https://www.googleapis.com/auth/userinfo.email"]
  },
  
"background": {
    "scripts": [
        "background.js",
        "runtime.js"
    ]
},
...
调用 chrome.identity API
API 上有一个名为 getAuthToken 的方法,我正在尝试调用它。当我尝试调用此方法时,我得到以下信息:
// background.ts
chrome.identity.getAuthToken({ interactive: true }, (token)  => {
  // store token here
});
错误

Unchecked runtime.lastError: OAuth2 request failed: Service responded with error: 'bad client id: 855289137522-bd37ggg68neqevqs47esitvc99rb5f8d.apps.googleusercontent.com'.


我检查了多次,我可以确认该 ID 与我的控制台开发人员凭据相同。
也许它需要 list 中的 key
我假设我的 manifest.json 中必须有一个 key 。所以,我关注了 documentation at the following link它说要按照以下步骤操作:
  1. At the Developer Dashboard, click Add new item.
  2. Click Choose file and select the .zip extension directory and upload it.
  3. Without filling in additional fields, select Save Draft and return to dashboard.

Find the extension under Your Listings and click on more info. From the popup, copy the public key and add it to the manifest inside the unzipped directory under the "key" field.


但是,我四处寻找,但找不到“更多信息”链接或任何其他引导我找到 key 的信息。

最佳答案

key 在新 UI 中可用 --> 左侧菜单中的包 --> 公钥

关于google-chrome - 您在哪里可以找到或如何创建 chrome 扩展 key 并将其放置在您的 manifest.json 文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61584996/

相关文章:

html - Chrome 中不显示背景图片

google-chrome - Chrome 中的SVG像素化

google-chrome - Web RTC 重新协商错误

javascript - Chrome 扩展程序化 UI 注入(inject)

asp.net-mvc - 什么最适合认证 ASP.NET MVC REST API? OAuth 2.0 还是 OAuth 1.0?

javascript - 从 Chrome 扩展程序运行 Google Apps 脚本

javascript - chrome.notifications 消息未显示

facebook-graph-api - Chrome 打包应用程序和 Facebook 重定向 url

Salesforce OAuth 2.0 API : get refresh_token with authorization URL launched in a normal browser

azure - 如何验证 Azure Active Directory 中刷新的 id_token 的签名