我使用oauth2-extension能够从chrome扩展程序中访问google-data http://smus.com/oauth2-chrome-extensions/
我修改了manifest.json,输入了JS中的数据并尝试进行身份验证但得到错误响应:
redirect_uri_mismatch [...] REDIRECT_URI = http://www.google.com/robots.txt
我很乐意将该网址添加到允许的redirect-urls中,但是在使用“本机应用程序”或“Chrome应用程序”时没有这样的选项我只是无法在Google的开发控制台上添加重定向URI。
有什么方法可以解决这个问题吗?
我的清单的一部分.Json:
"permissions": [
"http://ajax.googleapis.com/",
"storage",
"https://accounts.google.com/o/oauth2/token"
],
"content_scripts":
[{
"matches": ["https://plus.google.com/*"],
"js": [
"setup/js/jquery-1.10.2.min.js",
"date.js"]
},
{
"matches": ["http://www.google.com/robots.txt*"],
"js": ["oauth2/oauth2_inject.js"],
"run_at": "document_start"
}],
我的JS代码:
var googleAuth = new OAuth2('google', {
client_id: 'WHATEVER.apps.googleusercontent.com',
client_secret: 'HIDDEN',
api_scope: 'https://www.googleapis.com/auth/tasks'
});
function GetAuth()
{
googleAuth.authorize(function() {
alert('yippee ki yay!');
});
}
(当然“HIDDEN”和“WHATEVER”包含有效值)
答案 0 :(得分:2)
Google扩展示例中有一个oauth示例可以正常使用,我已经使用过了。但是你应该真正迁移到chrome身份,它可以帮助你。
答案 1 :(得分:1)
我有同样的问题,oauth2-extensions!我尝试编辑适配器文件adapter / google.js,如下所示
redirectURL: function(config) {
return 'your-redirect-url'; // here default redirect URL is http://www.google.com/robots.txt
}
这对我有用,但我不确定,如果这个API修改有任何问题,因为在documentation oauth2-extensions中没有提到这种类型。
此外,chrome.identity
是此任务最简单的选择!