omniauth-oauth
omniauth-oauth copied to clipboard
Handle invalid consumer credentials during request phase
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).
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 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.
Closing as stale