The current handling of API response error(s) in JupiterOneClient._execute_query, besides the status codes 429 and 503, expects the response content to be JSON, but that isn't always the case, such as 401 Unauthorized. This caused a JSONDecodeError to be thrown instead which obfuscated the actual error in the API response in which the content type was not application/json.
Added handling of 401 and other responses that aren't JSON.
Added tests for the new error handling.
Description
The current handling of API response error(s) in
JupiterOneClient._execute_query
, besides the status codes 429 and 503, expects the response content to be JSON, but that isn't always the case, such as 401 Unauthorized. This caused a JSONDecodeError to be thrown instead which obfuscated the actual error in the API response in which the content type was not application/json.Added handling of 401 and other responses that aren't JSON. Added tests for the new error handling.
References
auth0#12
Testing
I updated the pytests in test_client.py, but manual tests just require using a bogus account or token.
Checklist
master