zorkian / go-datadog-api

A Go implementation of the Datadog API.
BSD 3-Clause "New" or "Revised" License
183 stars 156 forks source link

Make API key validation succeed without app key #328

Closed KSerrania closed 3 years ago

KSerrania commented 3 years ago

Do not send the DD-APPLICATION-KEY header when the appkey is not set (ie. set to an empty string) on the client.

Sending a GET request to the api/v1/validate endpoint with a valid DD-API-KEY and no DD-APPLICATION-KEY succeeds. Sending a GET request to the api/v1/validate endpoint with a valid DD-API-KEY and DD-APPLICATION-KEY set to an empty string fails.

This PR allows the API key validation method to succeed even when only an API key is used (which is enough in some use cases where an app key is not needed to access relevant endpoints).

Use case: the datadog opentelemetry exporter, which uses this library to send metrics, and only requires an API key to do its operations.