chrome 分机认证身份 api
chrome extension authentication identity api
您好,我正在开发 chrome 扩展程序,我需要根据 Google Plus 帐户对用户进行身份验证。我已经用 Oauth 2.0 实现了。但是当我执行
时出现了一些问题
chrome.identity.getAuthToken({ 'interactive': true }
没有弹出 window 出现用于身份验证,我检查了 chrome://identity-internals/. 未找到令牌状态 我的分机。
我已完成 Chrome 身份 api 和用户身份验证过程
的所有步骤
我的扩展程序的应用程序 ID 与 Api 凭据中的相同 (Console.developer.google)
我已将 Public 密钥复制到 manifest.json
但还是没有希望。我在扩展后台页面手动尝试 chrome.identity.getAuthToken 我得到了这个错误
Unchecked runtime.lastError while running identity.getAuthToken: OAuth2 not granted or revoked.
我会在此处粘贴我的代码
Manifest.json
{
"name": "Tinpack",
"manifest_version": 2,
"version": "0.1",
"permissions": [
"identity",
"tabs",
"https://accounts.google.com/*",
"https://www.googleapis.com/*"
],
"background": {
"scripts": ["scripts/background.js"]
},
"browser_action": {
"default_icon": {
"19": "images/icon.png",
"38": "images/icon.png"
},
"default_title": "Tinpack",
"default_popup": "index.html"
},
"oauth2": {
"client_id": "my client id"
"scopes": [
"https://www.googleapis.com/auth/plus.login"
]
},
"key": "my public key"
"content_security_policy": "script-src 'self' 'unsafe-eval' https://apis.google.com/; object-src 'self'"
}
Background.js
chrome.identity.getAuthToken({
'interactive': true
}, function(token) {
if (chrome.runtime.lastError) {
alert("Error");
} else {
console.log(token);
alert(token);
}
});
有个小错误。在 Chrome webStore Dashboard 中创建的 ID 应该与 Oauth Conset Screen 中给出的 ID 相同。
您好,我正在开发 chrome 扩展程序,我需要根据 Google Plus 帐户对用户进行身份验证。我已经用 Oauth 2.0 实现了。但是当我执行
时出现了一些问题chrome.identity.getAuthToken({ 'interactive': true }
没有弹出 window 出现用于身份验证,我检查了 chrome://identity-internals/. 未找到令牌状态 我的分机。
我已完成 Chrome 身份 api 和用户身份验证过程
的所有步骤我的扩展程序的应用程序 ID 与 Api 凭据中的相同 (Console.developer.google)
我已将 Public 密钥复制到 manifest.json
但还是没有希望。我在扩展后台页面手动尝试 chrome.identity.getAuthToken 我得到了这个错误
Unchecked runtime.lastError while running identity.getAuthToken: OAuth2 not granted or revoked.
我会在此处粘贴我的代码
Manifest.json
{
"name": "Tinpack",
"manifest_version": 2,
"version": "0.1",
"permissions": [
"identity",
"tabs",
"https://accounts.google.com/*",
"https://www.googleapis.com/*"
],
"background": {
"scripts": ["scripts/background.js"]
},
"browser_action": {
"default_icon": {
"19": "images/icon.png",
"38": "images/icon.png"
},
"default_title": "Tinpack",
"default_popup": "index.html"
},
"oauth2": {
"client_id": "my client id"
"scopes": [
"https://www.googleapis.com/auth/plus.login"
]
},
"key": "my public key"
"content_security_policy": "script-src 'self' 'unsafe-eval' https://apis.google.com/; object-src 'self'"
}
Background.js
chrome.identity.getAuthToken({
'interactive': true
}, function(token) {
if (chrome.runtime.lastError) {
alert("Error");
} else {
console.log(token);
alert(token);
}
});
有个小错误。在 Chrome webStore Dashboard 中创建的 ID 应该与 Oauth Conset Screen 中给出的 ID 相同。