Skip to content

Commit

Permalink
renewed access token and refresh tokens are now updated back in the s…
Browse files Browse the repository at this point in the history
…ecrets store

Signed-off-by: Santhosh Gandhe <[email protected]>
  • Loading branch information
san81 committed Jan 13, 2025
1 parent aa7ca59 commit 0c34119
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public String updateValue(String secretId, String keyToUpdate, Object newValueTo

try {
final PutSecretValueResponse putSecretValueResponse = secretsManagerClient.putSecretValue(putSecretValueRequest);
LOG.info("Updated key: {} in the secret {}. New version of the store is {}",
keyToUpdate, secretId, putSecretValueResponse.versionId());
return putSecretValueResponse.versionId();
} catch (Exception e) {
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void renewCredentials() {
return;
}

log.info("Renewing access-refresh token pair for Jira Connector.");
log.info("Renewing access token and refresh token pair for Jira Connector.");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String payloadTemplate = "{\"grant_type\": \"%s\", \"client_id\": \"%s\", \"client_secret\": \"%s\", \"refresh_token\": \"%s\"}";
Expand All @@ -132,6 +132,9 @@ public void renewCredentials() {
this.refreshToken = (String) oauthClientResponse.get(REFRESH_TOKEN);
this.expiresInSeconds = (int) oauthClientResponse.get(EXPIRES_IN);
this.expireTime = Instant.ofEpochMilli(System.currentTimeMillis() + (expiresInSeconds * 1000L));
// updating config object's PluginConfigVariable so that it updates the underlying Secret store
jiraSourceConfig.getAuthenticationConfig().getOauth2Config().getRefreshToken().setValue(this.refreshToken);
log.info("Access Token and Refresh Token pair is now refreshed. Corresponding Secret store key updated.");
} catch (HttpClientErrorException ex) {
this.expireTime = Instant.ofEpochMilli(0);
this.expiresInSeconds = 0;
Expand Down

0 comments on commit 0c34119

Please sign in to comment.