diff --git a/src/Elastic.Apm/BackendComm/BackendCommUtils.cs b/src/Elastic.Apm/BackendComm/BackendCommUtils.cs index cb47daa17..d68a04db6 100644 --- a/src/Elastic.Apm/BackendComm/BackendCommUtils.cs +++ b/src/Elastic.Apm/BackendComm/BackendCommUtils.cs @@ -270,9 +270,9 @@ internal static HttpClient BuildHttpClient(IApmLogger loggerArg, IConfiguration } } - if (configuration.ApiKey != null) + if (!string.IsNullOrEmpty(configuration.ApiKey)) httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("ApiKey", configuration.ApiKey); - else if (configuration.SecretToken != null) + else if (!string.IsNullOrEmpty(configuration.SecretToken)) httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", configuration.SecretToken); return httpClient;