Skip to content

Commit

Permalink
Rename key to token to match influxdb header.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Belldina committed Sep 9, 2024
1 parent ee352ee commit b3bee6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public <T> T createClient(
String password,
String usernamePasswordFile,
String bearerToken,
String apiKey)
String apiToken)
throws IOException {
String baseUrl = remoteService.getBaseUrl();

Expand All @@ -138,9 +138,10 @@ public <T> T createClient(
&& StringUtils.isEmpty(password)
&& StringUtils.isEmpty(usernamePasswordFile)
&& StringUtils.isEmpty(bearerToken)
&& StringUtils.isEmpty(apiKey))) {
&& StringUtils.isEmpty(apiToken))) {
okHttpClient =
createAuthenticatedClient(username, password, usernamePasswordFile, bearerToken, apiKey);
createAuthenticatedClient(
username, password, usernamePasswordFile, bearerToken, apiToken);
}

Slf4jRetrofitLogger logger = createRetrofitLogger.apply(type);
Expand All @@ -161,7 +162,7 @@ private static OkHttpClient createAuthenticatedClient(
String password,
String usernamePasswordFile,
String bearerToken,
String apiKey)
String apiToken)
throws IOException {
final String credential;

Expand All @@ -172,8 +173,8 @@ private static OkHttpClient createAuthenticatedClient(
credential = "Basic " + Base64.encodeBase64String(trimmedFileContent.getBytes());
} else if (StringUtils.isNotEmpty(bearerToken)) {
credential = "Bearer " + bearerToken;
} else if (StringUtils.isNotEmpty(apiKey)) {
credential = "Token " + apiKey;
} else if (StringUtils.isNotEmpty(apiToken)) {
credential = "Token " + apiToken;
} else {
credential = Credentials.basic(username, password);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MetricsService influxDbMetricsService(
List<AccountCredentials.Type> supportedTypes = account.getSupportedTypes();

InfluxdbCredentials credentials =
InfluxdbCredentials.builder().apiKey(account.getApiKey()).build();
InfluxdbCredentials.builder().apiToken(account.getApiKey()).build();

InfluxDbNamedAccountCredentials.InfluxDbNamedAccountCredentialsBuilder
accountCredentialsBuilder =
Expand All @@ -92,7 +92,7 @@ MetricsService influxDbMetricsService(
null,
null,
null,
account.getApiKey()));
credentials.getApiToken()));
}
accountCredentialsBuilder.supportedTypes(supportedTypes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public class InfluxdbCredentials {
.orElse("Unknown");

private String dbName;
private String apiKey;
private String apiToken;
}

0 comments on commit b3bee6f

Please sign in to comment.