Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSRF detected error message on refreshing webpage

I am working on a Rails application where details are fetched from facebook. I have fetched the details from facebook. But when I refresh the webpage I got an error called CSRF detected. I have used some methods but all of them have failed.

The facebook Graph API is used in edit action.

These were added in inside class of Employees Controller.

  1. skip_before_action :verify_authenticity_token

  2. skip_before_action :verify_authenticity_token, only: [:edit]

  3. protect_from_forgery :only => [:edit]

  4. skip_before_action :authenticate_user, only: [:edit]

  5. skip_before_action :authenticate_user!

When authenticate_user is used(4th and 5th cases) I got an argument error, Before process_action callback :authenticate_user has not been defined.

In all other cases, the error when refreshing the page just after updating the page using facebook was OmniAuth::Strategies::OAuth2::CallbackError

csrf_detected | CSRF detected

PS: I have used 'omniauth-facebook' and 'koala' gem for the integration.

like image 924
NIkhil D Anand Avatar asked Jan 25 '18 10:01

NIkhil D Anand


2 Answers

I had this problem earlier, I tried the verify authenticity token earlier but it only worked out when I redirected the page So I request you to just redirect the page.

like image 84
Krishnaraj Rajendran Nair Avatar answered Oct 23 '22 19:10

Krishnaraj Rajendran Nair


do redirected_to to the page where the details needs to be printed.

like image 43
Ancy Paul Avatar answered Oct 23 '22 19:10

Ancy Paul