Rails / Doorkeeper: unable to authenticate CSRF token

I am using Rails 3.2 with the Doorkeeper gem to provide OAuth 2 APIs for third-party developers. I keep getting this warning when using my REST API outside the application:

WARNING: CSRF Token cannot be authenticated

The client application is successfully authenticated through OAuth2. Why am I getting this warning and how to properly implement this csrf for an external API?

+3
source share
2 answers

Remove protect_from_forgeryfrom your ApplicationController (or remove it for API calls).

+6
source

CSRF , ... , protect_from_forgery ApplicationController. create ... .

class MessagesController < ApplicationController
  protect_from_forgery with: :null_session, only: [:create]
  # doorkeeper_for :create
end

, .

, , ...

+2

All Articles