希望在我的 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它说要按照以下步骤操作:
- At the Developer Dashboard, click Add new item.
- Click Choose file and select the .zip extension directory and upload it.
- 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/