2

I'm trying to build an API using rails to use with an Android App, I've configured Devise and Doorkeeper, but I guess I forgot something...

I have this code in my controller:

doorkeeper_for :all
protect_from_forgery with: :null_session
respond_to :json

In the header

Authorization: Bearer b92d41ffd0723a77fcb8acd03e6e5be3b2f3036f07c9619f5bfb62611e31f42d

When I use GET method it works, but POST or DELETE don't

I get this error when I try to do a POST in my controller

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

Any suggestions?

Update

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

I have made no changes in default values of Devise

talski
  • 293
  • 2
  • 11
  • submit more details about `configuration` of `authentication` – mohameddiaa27 Nov 04 '14 at 15:54
  • I figured out what was going on, I put `skip_before_filter :verify_authenticity_token` in my controller and everything is working now, have any issue do this? – talski Nov 04 '14 at 23:11
  • 1
    This [answer](http://stackoverflow.com/questions/20745843/is-this-rails-json-authentication-api-using-devise-secure/20824818#20824818) may help. – mohameddiaa27 Nov 05 '14 at 01:54

0 Answers0