【问题标题】:How to integrate both authorization with OAuth and authentication with Devise in one step?如何一步将授权与 OAuth 以及与 Devise 的身份验证集成?
【发布时间】:2012-02-16 08:13:32
【问题描述】:

我设法按照本教程和 oauth-plugin 获得授权:http://unhandledexpression.com/2011/06/02/rails-and-oauth-plugin-part-1-the-provider/

但是,在移动应用程序上下文中,我被困在如何一步完成授权和身份验证(使用 Devise) - 因为用户已经登录以获取 oauth 访问令牌。

class ApiController < ApplicationController

  before_filter :oauth_required

  def current_user=(user)
      current_user = user
  end

  def show_current_user
      puts current_user ### nil
  end
end

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails-3 oauth devise


    【解决方案1】:

    所以你的问题是,为什么 current_user 是零?或者您有类似以下的问题? OAuth2 Provider: How to offer a login page in order to let oauth clients get the resource owner id

    您应该使用(尚未记录的)oauthenticate 方法,而不是 before_filter。

    类 ApiController

    验证

    结束

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 1970-01-01
      • 2011-09-27
      • 1970-01-01
      • 2014-09-28
      • 2014-02-23
      • 2019-10-11
      • 2020-03-07
      相关资源
      最近更新 更多