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?
Remove protect_from_forgeryfrom your ApplicationController (or remove it for API calls).
protect_from_forgery
CSRF , ... , protect_from_forgery ApplicationController. create ... .
ApplicationController
class MessagesController < ApplicationController protect_from_forgery with: :null_session, only: [:create] # doorkeeper_for :create end
, .
, , ...