Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Always return response from _do_http_method
Noticed a bug where the *first* time we queried an API after a long time (in this case Sierra), we'd see a json decode error coming from the requests modules `response.json()`. Since we weren't calling it on our end, I dug through the trace a little and found that we call `.json()` in this library *only* when the token is expired and we do a refresh, which would explain the timing of the bug. So simply, make sure to return the raw response object when we do a token refresh. Here's an example stacktrace of the bug we are encountering: File /ereadingserver/./app/main.py, line 186, in login File /ereadingserver/./app/auth/login.py, line 62, in log_in_with_card File /ereadingserver/./app/sierra.py, line 106, in patron_is_valid File /usr/local/lib/python3.10/site-packages/nypl_py_utils/classes/oauth2_api_client.py, line 63, in post File /usr/local/lib/python3.10/site-packages/nypl_py_utils/classes/oauth2_api_client.py, line 106, in _do_http_method File /usr/local/lib/python3.10/site-packages/requests/models.py, line 975, in json
- Loading branch information