How to rescue OmniAuth::Strategies::OAuth2::CallbackError?

后端 未结 4 456
名媛妹妹
名媛妹妹 2021-01-30 13:23

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\' b

4条回答
  •  一生所求
    2021-01-30 13:46

    I have solved this problem with the Fabio's first suggestion.

    OmniAuth.config.on_failure = Proc.new do |env|
      UsersController.action(:omniauth_failure).call(env)
      #this will invoke the omniauth_failure action in UsersController.
    end
    

    In my UsersController

    class UsersController < ActionController::Base
      def omniauth_failure
        redirect_to init_sign_in_users_path
        #redirect wherever you want.
      end
    end
    

提交回复
热议问题