【问题标题】:oauth2 flow using doorkeeper with chrome extensionoauth2 流使用带有 chrome 扩展的门卫
【发布时间】:2017-06-02 05:14:12
【问题描述】:

我有一个 chrome 扩展程序,我想将其用作我的 rails 应用程序的 oauth2 客户端,使用 doorkeeper 和 devise。在我的扩展中

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

在 doorkeeper admin 中,我的这个客户端的回调 url 是 https://galaiojniedmogfplghkjnmcfnlbpbpg.chromiumapp.org/,我通过调用 chrome.identity.getRedirectUrl() 检索到它。

我在这里错过了什么?

【问题讨论】:

  • 您可能想查看来自User Authentication 文档的GitHub 示例。这显示了launchWebAuthFlow 的 google 实现示例,将其作为基本参考将有助于跟踪未定义 redirect_url 的原因。希望这会有所帮助。

标签: ruby-on-rails google-chrome-extension doorkeeper


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-01-12
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多