title: How to rescue OmniAuth::Strategies::OAuth2::CallbackError?
body: <p>I am building a Rails application with <a href="https://github.com/intridea/omniauth" rel="nofollow noreferrer">Omniauth</a> for log in service.To authenticate Google I am using <a href="https://github.com/zquestz/omniauth-google-oauth2" rel="nofollow noreferrer">OmniAuth Google OAuth2 Strategy</a>.</p>
  <p>When user clicks 'allow access' button everything works fine.But when user clicks 'no thanks' button the below error is raised.</p>
  <pre><code>OmniAuth::Strategies::OAuth2::CallbackError
  </code></pre>
  <p>I have tried adding the below rescue code in application controller.</p>
  <pre><code>class ApplicationController &lt; ActionController::Base
    rescue_from OmniAuth::Strategies::OAuth2::CallbackError, :with =&gt;
      :omniauth_callback_error_handler
  
   protected
  
   def omniauth_callback_error_handler
    redirect_to init_sign_in_users_path
   end
  end
  </code></pre>
  <p>But no luck. Any idea?</p>