-
-
Notifications
You must be signed in to change notification settings - Fork 425
Fail-fast on server errors. #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Most OAuth providers give HTTP error codes if something goes wrong. Call raise_for_status() instead of failing with MissingTokenError. The call is *after* the blocks of debug statements so that you can still figure out what went wrong, if you know where to look.
We very deliberately removed |
Thanks for the explanation! That answers my implicit question about why this line was missing, then. I ran into this when I was slightly misusing redirect_uri with Facebook. By turning on logging I could see "Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request", but that message gets buried the way the code is now. I would like to find a way to wrap these errors into python exceptions. Here's the full reply. You can see that Facebook gives the message in both
It would be a lot more useful I could get that OAuthException python-side! Which providers are giving data on 4xxs? Could they be handled with a
|
@kousu I think that's a fundamentally bad idea (changing a status code). The library could provide more information in the exception instance to help you figure out what's available (or the Facebook integration could have a compliance fix for having the exception message in tl;dr Improving information discoverable on exceptions: 👍 ; Hiding information about responses by changing attributes and information on the response: very strong 👎 |
Since this pull request hasn't had any activity in over two years, I'm closing it. |
It is misleading to raise a MissingTokenError when the server has returned an HTTP server error. Instead, raise requests.exceptions.HTTPError if the server has returned an HTTP 5XX server error. Prior PR conversation in PR requests#217 indicates that the maintainers do not want to raise on 4XX errors due to certain providers using those responses to send data. So we need a custom handler with a slight variation on the built-in requests.models.Response.raise_for_status().
Most OAuth providers give HTTP error codes if something goes wrong. This calls raise_for_status() instead of failing with MissingTokenError in that case, which is uninformative.
The call is after the blocks of debug statements so that you can still figure out what went wrong, if you know where to look.