mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
Use claims to force an idToken in Broker flow (#236623)
Looks like the Broker doesn't support `forceRefresh`... This is an alternative way of forcing a refresh. Fixes https://github.com/microsoft/vscode/issues/229456
This commit is contained in:
committed by
GitHub
parent
8be4be068e
commit
d55cb9a7a0
@@ -102,9 +102,19 @@ export class CachedPublicClientApplication implements ICachedPublicClientApplica
|
||||
);
|
||||
if (fiveMinutesBefore < new Date()) {
|
||||
this._logger.debug(`[acquireTokenSilent] [${this._clientId}] [${this._authority}] [${request.scopes.join(' ')}] [${request.account.username}] id token is expired or about to expire. Forcing refresh...`);
|
||||
result = await this._sequencer.queue(() => this._pca.acquireTokenSilent({ ...request, forceRefresh: true }));
|
||||
const newRequest = this._isBrokerAvailable
|
||||
// HACK: Broker doesn't support forceRefresh so we need to pass in claims which will force a refresh
|
||||
? { ...request, claims: '{ "id_token": {}}' }
|
||||
: { ...request, forceRefresh: true };
|
||||
result = await this._sequencer.queue(() => this._pca.acquireTokenSilent(newRequest));
|
||||
this._logger.debug(`[acquireTokenSilent] [${this._clientId}] [${this._authority}] [${request.scopes.join(' ')}] [${request.account.username}] got refreshed result`);
|
||||
}
|
||||
const newIdTokenExpirationInSecs = (result.idTokenClaims as { exp?: number }).exp;
|
||||
if (newIdTokenExpirationInSecs) {
|
||||
if (new Date(newIdTokenExpirationInSecs * 1000) < new Date()) {
|
||||
this._logger.error(`[acquireTokenSilent] [${this._clientId}] [${this._authority}] [${request.scopes.join(' ')}] [${request.account.username}] id token is still expired.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this._setupRefresh(result);
|
||||
|
||||
Reference in New Issue
Block a user