我正在尝试使用 Rails 构建一个 API 以与 Android 应用程序一起使用,我已经配置了 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."}
有什么建议么?
更新
看门人.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
我没有更改设计的默认值