skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. do redirected_to to the page where the details needs to be printed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search