Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,12 @@ public HeaderFactory configure(DatabricksConfig config) {
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", String.format("Bearer %s", idToken.getTokenValue()));

if (config.getClientType() == ClientType.ACCOUNT) {
AccessToken token;
try {
token = finalServiceAccountCredentials.createScoped(GCP_SCOPES).refreshAccessToken();
} catch (IOException e) {
String message =
"Failed to refresh access token from Google service account credentials.";
LOG.error(message + e);
throw new DatabricksException(message, e);
}
try {
AccessToken token =
finalServiceAccountCredentials.createScoped(GCP_SCOPES).refreshAccessToken();
headers.put(SA_ACCESS_TOKEN_HEADER, token.getTokenValue());
} catch (IOException e) {
LOG.warn("Failed to refresh GCP SA access token, skipping header: {}", e.getMessage());
}

return headers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ public HeaderFactory configure(DatabricksConfig config) {
throw new DatabricksException(message, e);
}

if (config.getClientType() == ClientType.ACCOUNT) {
try {
headers.put(
SA_ACCESS_TOKEN_HEADER, gcpScopedCredentials.refreshAccessToken().getTokenValue());
} catch (IOException e) {
String message = "Failed to refresh access token from scoped id token credentials.";
LOG.error(message + e);
throw new DatabricksException(message, e);
}
try {
headers.put(
SA_ACCESS_TOKEN_HEADER, gcpScopedCredentials.refreshAccessToken().getTokenValue());
} catch (IOException e) {
LOG.warn("Failed to refresh GCP SA access token, skipping header: {}", e.getMessage());
}

return headers;
Expand Down
Loading