devise icon indicating copy to clipboard operation
devise copied to clipboard

Improved failure_message to interpret OAuth2::Error

Open coezbek opened this issue 4 years ago • 1 comments

OAuth2::Error Exceptions do not have error_reason and error as the Omniauth::CallbackError, but rather use the fields description and code.

This is particularly useful if the error is returned server-side and handled by OAuth2.

See: callback_phase can return OAuth2::Error or CallbackError https://github.com/omniauth/omniauth-oauth2/blob/561ddcef4d7791bc46ff1d718de5db13894d8033/lib/omniauth/strategies/oauth2.rb#L84

See: Definition of CallbackError https://github.com/omniauth/omniauth-oauth2/blob/561ddcef4d7791bc46ff1d718de5db13894d8033/lib/omniauth/strategies/oauth2.rb#L149

See: Definition of OAuth2::Error https://github.com/oauth-xx/oauth2/blob/1940e9ad6f395b2fb80f09e4140d17fe0344325a/lib/oauth2/error.rb#L4

coezbek avatar Nov 29 '21 23:11 coezbek

hi @coezbek I'm just looking at this part of the code now, and I've noticed that in certain situations an actual exception object is returned whcih doesn't have reason, error, code or description BUT does have .message, as in error.message.

Would be great it we could also add

error ||= exception.message        if exception.respond_to?(:message)

What do you think?

thatandyrose avatar Jan 31 '22 16:01 thatandyrose