2017-06-02 98 views
0

我有一个铬扩展我想作为oauth2客户端使用守门人和设计我的rails应用程序。在扩展中,我有使用门卫与铬扩展oauth2流

chrome.identity.launchWebAuthFlow(
    {'url': 'http://localhost:3000/oauth/authorize?client_id=98c0af01eec1004144f32a6fd5d114b40efcd01771e24a7190f2acd06ac552c8&redirect_uri=https://galaiojniedmogfplghkjnmcfnlbpbpg.chromiumapp.org?response_type=code&scope=', 'interactive': true}, 
    function(redirect_url) { 
    /* Extract token from redirect_url */ 
    console.log(redirect_url) 
    } 
); 

这会启动一个窗口,要求我使用我的rails应用程序登录。登录并关闭此窗口后,运行console.log,但redirect_urlundefined

在门卫管理我的这个客户端的回调url是https://galaiojniedmogfplghkjnmcfnlbpbpg.chromiumapp.org/我通过调用chrome.identity.getRedirectUrl()检索。

我在这里错过了什么?

+0

您可能想要检查[User Authentication](https://developer.chrome.com/)中的[GitHub](https://github.com/GoogleChrome/chrome-app-samples#_sample_github-auth)示例apps/app_identity)文档。这显示了'launchWebAuthFlow'的谷歌实现示例,将其作为基础引用将帮助跟踪为什么redirect_url未定义。希望这可以帮助。 –

回答

0

这是我如何设置门卫的问题。因为我在重定向之前进行了会话身份验证,所以它返回了301.确保您的身份验证在Chrome扩展流程之外工作,然后再将其挂接到扩展。