nhosoya / omniauth-apple

OmniAuth strategy for Sign In with Apple
MIT License
264 stars 101 forks source link

user_cancelled_authorize: OmniAuth::Strategies::OAuth2::CallbackError, user_cancelled_authorize #23

Closed booleanbetrayal closed 2 years ago

booleanbetrayal commented 4 years ago

Seems that this gem results in a OmniAuth::Strategies::OAuth2::CallbackError being raised when the user cancels the Sign in with Apple flow, after supplying their credentials, when presented with the Cancel / Continue buttons.

Here appears to be some relevant code in omniauth-oauth2: https://github.com/omniauth/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L66-L83

Wondering if this is something this gem should explicitly try to suppress.

skotchpine commented 3 years ago

Given the rhythm of collaboration here, it might be worth writing a pull-request to add the option?

dreucodi commented 2 years ago

For those looking for quick-and-dirty handling of this error:

Rails.application.config.to_prepare do
  OmniAuth::Strategies::Apple.class_eval do
    # Patched to handle user cancel event
    def callback_call
      if request.params["error"] == "user_cancelled_authorize"
        return redirect whatever_url
      end

      super
    end
  end
end
nov commented 2 years ago

you can define failure callback at OmniAuth.config.on_failure https://github.com/omniauth/omniauth/blob/a62d36b3f847e0e55b077790112e96950c35085a/lib/omniauth/strategy.rb#L533-L545