I created an api key in datadog by going to Organization Setting > Api Key > New Key
On the datadog authentication docs this is how you test if your key is valid:
<code>// Validate API key returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewAuthenticationApi(apiClient)
resp, r, err := api.Validate(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AuthenticationApi.Validate`: %vn", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %vn", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AuthenticationApi.Validate`:n%sn", responseContent)
}
</code>
<code>// Validate API key returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewAuthenticationApi(apiClient)
resp, r, err := api.Validate(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AuthenticationApi.Validate`: %vn", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %vn", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AuthenticationApi.Validate`:n%sn", responseContent)
}
</code>
// Validate API key returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewAuthenticationApi(apiClient)
resp, r, err := api.Validate(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AuthenticationApi.Validate`: %vn", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %vn", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AuthenticationApi.Validate`:n%sn", responseContent)
}
Then it says to run:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"
Why am I getting 403 forbidden ;-;
I tried making new keys but I dont know what else to do