0

我使用的oauth2扩展到能够从访问铬扩展在谷歌数据 http://smus.com/oauth2-chrome-extensions/如何在Chrome扩展中为OAuth2提供重定向网址?

我修改了manifest.json中,进入在JS中的数据,并尝试进行身份验证,但得到一个错误 - 回应:

redirect_uri_mismatch [...] REDIRECT_URI = http://www.google.com/robots.txt

我很想该网址添加到允许的重定向的URL,但使用时有没有这样的选项“呐tive应用程序“或”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!'); 
    }); 
} 

(当然 “隐藏” 和 “无所谓” 包含有效值)

回答

2

有是谷歌扩展示例中的oauth示例,可以正常使用。但是,你应该真正迁移到铬身份,这一切都为你做。

+0

我不能相信它是多么容易与铬身份工作... :)感谢朋友。 –

+2

只要注意用户需要登录到chrome而旧的方法没有。 –

+0

它不再工作,重定向到支持页面 – Poutrathor

1

我的问题与oauth2-extensions相同!我试图编辑适配器文件适配器/ google.js,如下

redirectURL: function(config) { 
    return 'your-redirect-url'; // here default redirect URL is http://www.google.com/robots.txt 
    } 

这为我工作,但我不知道,如果有这个API修改的任何问题,因为在documentation为的oauth2的扩展没有提到这种类型。

此外,chrome.identity是这项任务的最简单的选择!

相关问题