omniauth-oauth icon indicating copy to clipboard operation
omniauth-oauth copied to clipboard

Handle invalid consumer credentials during request phase

Open mkdynamic opened this issue 9 years ago • 2 comments

Encountered an OAuth::Unauthorized exception during the request phase, when passing invalid credentials. Specifically, when using the omniauth-desk gem. Here's the relevant part of the stacktrace:

It seems like this could happen in other OAuth 1 stategies too, when the consumer is constructed. I'm not 100% sure if :invalid_credentials is the right failure code, but it seems like the closest since this is about invalid credentials (only for the consumer).

mkdynamic avatar Jul 11 '15 21:07 mkdynamic

Great! I've been having some errors in production because twitter oauth API is returning 404, and oauth gem does this:

def token_request(http_method, path, token = nil, request_options = {}, *arguments)
  ...
  when (400..499)
    raise OAuth::Unauthorized, response
  ...
end

So, this PR is broader than just handling invalid consumer credentials. This resolves any client response in the 400..499 response codes range.

telmofcosta avatar Jul 29 '15 15:07 telmofcosta

@telmofcosta Good info. I don't think this PR changes anything about that, the code currently raises a OAuth::Unauthorized for the 404. Perhaps you could open a PR to fix that.

mkdynamic avatar Sep 02 '16 03:09 mkdynamic

Closing as stale

BobbyMcWho avatar Aug 27 '24 16:08 BobbyMcWho