【发布时间】:2014-03-06 16:32:49
【问题描述】:
我使用 oauth2-extension 能够从 chrome-extension 中访问 google-data http://smus.com/oauth2-chrome-extensions/
我修改了manifest.json,在JS中输入数据并尝试认证但得到错误响应:
redirect_uri_mismatch [...] redirect_uri=http://www.google.com/robots.txt
我很想将该 url 添加到允许的重定向 url,但是在使用“本机应用程序”或“chrome 应用程序”时没有这样的选项,我只是无法在 Google 的开发控制台上添加重定向 URI。
有什么办法可以解决这个问题?
我的 manifest.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”包含有效值)
【问题讨论】:
标签: javascript google-chrome-extension oauth oauth-2.0 google-api