How to Handle OAuth::Unauthorized error for Omniauth provider?

Add this piece of code in your initializer file
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, twitter_consumer_key, twitter_consumer_secret
end 
OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}
This will redirect user to the failure page, instead of showing an error.

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Remove duplicates from a JavaScript Array

Sending Binary Data over the Network with Json