diff --git a/.generator/src/generator/templates/configuration.j2 b/.generator/src/generator/templates/configuration.j2 index 663b1c52b4..e1b44cfcf1 100644 --- a/.generator/src/generator/templates/configuration.j2 +++ b/.generator/src/generator/templates/configuration.j2 @@ -248,9 +248,9 @@ class Configuration: # Load default values from environment if "DD_SITE" in os.environ: self.server_variables["site"] = os.environ["DD_SITE"] - if "DD_API_KEY" in os.environ: + if "DD_API_KEY" in os.environ and not self.api_key.get("apiKeyAuth"): self.api_key["apiKeyAuth"] = os.environ["DD_API_KEY"] - if "DD_APP_KEY" in os.environ: + if "DD_APP_KEY" in os.environ and not self.api_key.get("appKeyAuth"): self.api_key["appKeyAuth"] = os.environ["DD_APP_KEY"] def __deepcopy__(self, memo): diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index f821ebd5bb..a06f089db6 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -284,9 +284,9 @@ def __init__( # Load default values from environment if "DD_SITE" in os.environ: self.server_variables["site"] = os.environ["DD_SITE"] - if "DD_API_KEY" in os.environ: + if "DD_API_KEY" in os.environ and not self.api_key.get("apiKeyAuth"): self.api_key["apiKeyAuth"] = os.environ["DD_API_KEY"] - if "DD_APP_KEY" in os.environ: + if "DD_APP_KEY" in os.environ and not self.api_key.get("appKeyAuth"): self.api_key["appKeyAuth"] = os.environ["DD_APP_KEY"] def __deepcopy__(self, memo):