auth0 / jupiterone-python-sdk

A Python client for jupiterone.io
MIT License
10 stars 17 forks source link

Improve response error handling - Fixes auth0 Issue 12 #13

Closed lmarkscp closed 1 year ago

lmarkscp commented 2 years ago

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

SeaBlooms commented 1 year ago

@gvauter can this be merged?