I am building a Rails application with Omniauth for log in service.To authenticate Google I am using OmniAuth Google OAuth2 Strategy.
When user clicks 'allow access' button everything works fine.But when user clicks 'no thanks' button the below error is raised.
OmniAuth::Strategies::OAuth2::CallbackError
I have tried adding the below rescue code in application controller.
class ApplicationController < ActionController::Base rescue_from OmniAuth::Strategies::OAuth2::CallbackError, :with => :omniauth_callback_error_handler protected def omniauth_callback_error_handler redirect_to init_sign_in_users_path end end
But no luck.
Any idea?
Thank you :)
You can set the on_failure proc in the omniauth initializer in an even cleaner fashion:
OmniAuth.config.on_failure = UsersController.action(:oauth_failure)
1.4m articles
1.4m replys
5 comments
57.0k users