signalfx / signalfx-python

Python client library and instrumentation bindings for SignalFx (Deprecated)
https://www.signalfx.com
Apache License 2.0
43 stars 47 forks source link

POST call return error if API token is invalid #137

Open rsanchuk opened 1 year ago

rsanchuk commented 1 year ago

This change will allow the user to receive an error in case the user's API TOKEN is invalid or the authentication didn't go through. Currently, the user receives no response if the API TOKEN is invalid. This might mislead the user into thinking everything went well when it doesn't.

In previous attempts to add this minor fix, a test was required. So I also added a validation test to the test_data_reporting file to check if we indeed receive an error, and this is the output we will get in case of an invalid token:

ERROR:root:401 Client Error: Unauthorized for url: https://ingest.signalfx.com/v2/event
ERROR:root:401 Client Error: Unauthorized for url: https://ingest.signalfx.com/v2/datapoint
ERROR:root:401 Client Error: Unauthorized for url: https://ingest.signalfx.com/v2/datapoint

Let me know if something else is required.