门卫和Devise在POST时获得401 Unauthorized

时间:2014-11-04 15:48:41

标签: ruby-on-rails ruby devise doorkeeper

我正在尝试使用rails构建一个与Android应用程序一起使用的API,我已经配置了Devise和Doorkeeper,但我想我忘了一些......

我的控制器中有这个代码:

doorkeeper_for :all
protect_from_forgery with: :null_session
respond_to :json

在标题

Authorization: Bearer b92d41ffd0723a77fcb8acd03e6e5be3b2f3036f07c9619f5bfb62611e31f42d

当我使用GET方法时,它可以工作,但POST或DELETE不能

当我尝试在控制器中执行POST时出现此错误

{"error": "You need to sign in or sign up before continuing."}

有什么建议吗?

更新

doorkeeper.rb

Doorkeeper.configure do
  orm :active_record

  resource_owner_authenticator do
    current_usuario || warden.authenticate!(:scope => :usuario)
  end

  resource_owner_from_credentials do |routes|
    request.params[:usuario] = {:email => request.params[:username], :password => request.params[:password]}
    request.env["devise.allow_params_authentication"] = true
    request.env["warden"].authenticate!(:scope => :usuario)
  end
end

我没有对Devise的默认值进行任何更改

0 个答案:

没有答案
相关问题