Skip to content

Commit 736c759

Browse files
VIA-254 Temporarily add logging of APIM expiry times
1 parent 1b0bd8e commit 736c759

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/utils/auth/apim/get-apim-access-token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const getApimAccessToken = async (): Promise<AccessToken> => {
2222
log.error({ context: { token } }, "APIM access token is not present on JWT token");
2323
throw new ApimMissingTokenError("APIM access token is not present on JWT token");
2424
}
25+
log.info(`Preparing to fetch-eligibility-content: APIM expires at ${token.apim.expires_at}`);
2526
return token.apim.access_token;
2627
};
2728

src/utils/auth/callbacks/get-token.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ async function _getOrRefreshApimCredentials(config: AppConfig, token: JWT, nowIn
8080
"getOrRefreshApimCredentials: Getting new APIM creds.",
8181
);
8282
updatedApimCredentals = await retrieveApimCredentials(token.nhs_login.id_token);
83+
log.info(`First APIM token fetched. expiry time: ${token.apim.expires_at}`);
8384
log.debug({ context: { updatedApimCredentals } }, "getOrRefreshApimCredentials: New APIM creds retrieved.");
8485
} else {
8586
const expiryWriggleRoom = 30;
@@ -90,11 +91,15 @@ async function _getOrRefreshApimCredentials(config: AppConfig, token: JWT, nowIn
9091
{ context: { existingApimCredentals: token.apim } },
9192
"getOrRefreshApimCredentials: Refreshing APIM creds.",
9293
);
94+
95+
log.info(`APIM token expires soon ${token.apim.expires_at} ; fetching new token`);
9396
updatedApimCredentals = await retrieveApimCredentials(token.nhs_login.id_token);
9497
log.debug(
9598
{ context: { updatedApimCredentals } },
9699
"getOrRefreshApimCredentials: Refreshed APIM creds retrieved.",
97100
);
101+
102+
log.info(`New APIM token fetched. expiry time: ${token.apim.expires_at}`);
98103
} else {
99104
log.debug(
100105
{ context: { existingApimCredentals: token.apim, timeRemaining: expiresSoonAt - nowInSeconds } },

0 commit comments

Comments
 (0)