diff --git a/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts b/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts index 3cc74ad422de..d564e2a44e81 100644 --- a/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts +++ b/sdk/identity/identity/src/credentials/managedIdentityCredential/index.ts @@ -253,9 +253,14 @@ export class ManagedIdentityCredential implements TokenCredential { if (resultToken) { logger.info(`SetAppTokenProvider has saved the token in cache`); logger.info(`token = ${resultToken.token}`); + + const expiresInSeconds = resultToken?.expiresOnTimestamp + ? Math.floor((resultToken.expiresOnTimestamp - Date.now()) / 1000) + : 0; + return { accessToken: resultToken?.token, - expiresInSeconds: resultToken?.expiresOnTimestamp / 1000, + expiresInSeconds, }; } else { logger.info(