requests / requests-oauthlib

OAuthlib support for Python-Requests!
https://requests-oauthlib.readthedocs.org/
ISC License
1.71k stars 422 forks source link

`fetch_token` should check the `status_code` of the response before parsing the result #446

Open hhowe29 opened 3 years ago

hhowe29 commented 3 years ago

This block of code should check the status_code of the response before parsing. If the server returns a 403, or any non 2xx code for that matter, then that error should propagate out to the caller. The current code just goes ahead and tries to parse the response text as json. On a 403, the response body is likely to be html

https://github.com/requests/requests-oauthlib/blob/46f886ccb74652fc9c850ece960edcf2bce765a5/requests_oauthlib/oauth2_session.py#L341-L366