Unable to authenticate CSRF token when calling Rails with Android

I get โ€œCan't Authenticate CSRF Tokenโ€ when I try to use an Android app to invoke the create action on one of the controllers in my rails service. Also says "Completed 422 Unprocessable Entity" after that. Any ideas what this would cause? Thank.

+4
source share
1 answer

You can disable the built-in CSRF protection. Rails uses by default, adding to your controller (ApplicationController or the one that is used) protect_from_forgery:

protect_from_forgery with: :null_session

Or also using skip_before_actionto skip the implementation verify_authenticity_token.

+1
source

Source: https://habr.com/ru/post/1679536/


All Articles