-
Notifications
You must be signed in to change notification settings - Fork 315
Description
Describe the bug
The issue arose when using API KEYS and APP KEYS in options, initializing the module and testing a first option.
Same as : #169
Traceback (most recent call last):
File "/Users/user/./datadog_scrapper.py", line 12, in <module>
print(api.Monitor.get_all())
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/datadog/api/monitors.py", line 72, in get_all
return super(Monitor, cls).get_all(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/datadog/api/resources.py", line 220, in get_all
return APIClient.submit("GET", cls._resource_name, api_version, **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/datadog/api/api_client.py", line 193, in submit
raise ValueError("Invalid JSON response: {0}".format(content))
ValueError: Invalid JSON response: b'<!DOCTYPE html>\\n<html lang="en">\\n<head>\\n\t<meta charset="utf-8" />\\n\t<title>Forbidden</title>\\n\t<style>\\n\t\t/* 960 stuff: */\\n\t\t/* reset */\\n\t\thtml,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,e
Label the issue properly:
- Non severe
To Reproduce
Steps to reproduce the behavior:
- Create an APP token, retrieve the secret
- (Optional but should be noted) Save the env var through direnv and load it on os.environ
- Run :
from datadog import initialize, api
import os
options = {
"api_key": f"{os.environ['DATADOG_API_KEY']}",
"app_key": f"{os.environ['DATADOG_APP_KEY']}",
"api_host": "https://app.datadoghq.eu"
}
initialize(**options)
print(api.Monitor.get_all())
Expected behavior
Most likely, the APP and API keys are either wrong, not approved yet, I should receive either a general token error upon connection (on the initialize part), or a specific error associated to my case on the api call ( wrong, not authorized on this scope, token approval, expiration if any)
Environment and Versions (please complete the following information):
Using Mac OS :root:xnu-11417.101.15~1/RELEASE_ARM64_T8122 arm64 arm Darwin
Using Python 3.12.8 environment at: /Library/Frameworks/Python.framework/Versions/3.12
ansible==11.1.0
ansible-core==2.18.1
boto3==1.37.6
botocore==1.37.6
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
cryptography==44.0.0
datadog==0.51.0
idna==3.10
jinja2==3.1.5
jmespath==1.0.1
markupsafe==3.0.2
packaging==24.2
pip==24.3.1
pycparser==2.22
python-dateutil==2.9.0.post0
pyyaml==6.0.2
requests==2.32.3
resolvelib==1.0.1
s3transfer==0.11.4
six==1.17.0
urllib3==2.3.0