我使用 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
我很想将该网址添加到允许的重定向网址中,但在使用“ native 应用程序”或“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”包含有效值)
最佳答案
谷歌扩展示例中有一个 oauth 示例,工作正常,我使用过它。但您确实应该迁移到 chrome 身份,它可以为您完成这一切。
关于javascript - 如何在 Chrome 扩展中为 OAuth2 提供重定向 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21658659/