我使用oauth2-extension能够从chrome扩展名http://smus.com/oauth2-chrome-extensions/中访问google-data
我修改了manifest.json,在JS中输入了数据,然后尝试进行身份验证,但收到了错误响应:
redirect_uri_mismatch [...] redirect_uri = http://www.google.com/robots.txt
我很乐意将该URL添加到允许的重定向URL中,但是当使用“本机应用程序”或“ chrome应用程序”时没有这种选择,我只是无法在Google开发控制台中添加重定向URI。
有什么办法解决这个问题?
我清单的一部分。杰森:
"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”包含有效值)
在google扩展示例中有一个oauth示例可以正常工作,我用过它。但是您应该真正迁移到chrome身份标识,这将为您完成所有工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句