Skip to content

Commit 70211b7

Browse files
committed
Fix expires_in assignment and refresh token update
Corrects the assignment of expires_in to preserve 0 and undefined values, and updates the in-memory refresh token if the provider rotates it during access token refresh.
1 parent e812aff commit 70211b7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/src/Components/APICall/AccessTokenManager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,13 @@ class AccessTokenManager {
147147
// Update internal tokensData reference
148148
this.tokensData = updatedData;
149149
this.primaryToken = newAccessToken;
150-
this.expires_in = expirationTimestamp ? expirationTimestamp.toString() : expirationTimestamp;
151-
150+
// Update in-memory refresh token in case the provider rotated it
151+
this.secondaryToken = (response?.data?.refresh_token ?? this.secondaryToken);
152+
// Preserve 0 and avoid dropping undefined
153+
this.expires_in =
154+
(expirationTimestamp ?? undefined) !== undefined
155+
? String(expirationTimestamp)
156+
: undefined;
152157
return newAccessToken;
153158
} catch (error) {
154159
console.error('Failed to refresh access token:', error);

0 commit comments

Comments
 (0)