diff --git a/src/vs/workbench/api/browser/mainThreadAuthentication.ts b/src/vs/workbench/api/browser/mainThreadAuthentication.ts index 7b31bb4a789..4545e3c2a8d 100644 --- a/src/vs/workbench/api/browser/mainThreadAuthentication.ts +++ b/src/vs/workbench/api/browser/mainThreadAuthentication.ts @@ -121,7 +121,8 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu // Prefer Node.js extension hosts when they're available. No CORS issues etc. priority: extHostContext.extensionHostKind === ExtensionHostKind.LocalWebWorker ? 0 : 1, create: async (authorizationServer, serverMetadata, resource) => { - const authProviderId = authorizationServer.toString(true); + // Auth Provider Id is a combination of the authorization server and the resource, if provided. + const authProviderId = resource ? `${authorizationServer.toString(true)} ${resource.resource}` : authorizationServer.toString(true); const clientId = this.dynamicAuthProviderStorageService.getClientId(authProviderId); let initialTokens: (IAuthorizationTokenResponse & { created_at: number })[] | undefined = undefined; if (clientId) { diff --git a/src/vs/workbench/api/common/extHostAuthentication.ts b/src/vs/workbench/api/common/extHostAuthentication.ts index 00dc61b1b72..a9a03b472d2 100644 --- a/src/vs/workbench/api/common/extHostAuthentication.ts +++ b/src/vs/workbench/api/common/extHostAuthentication.ts @@ -284,12 +284,14 @@ export class DynamicAuthProvider implements vscode.AuthenticationProvider { initialTokens: IAuthorizationToken[], ) { const stringifiedServer = authorizationServer.toString(true); + // Auth Provider Id is a combination of the authorization server and the resource, if provided. this.id = _resourceMetadata?.resource ? stringifiedServer + ' ' + _resourceMetadata?.resource : stringifiedServer; + // Auth Provider label is just the resource name if provided, otherwise the authority of the authorization server. this.label = _resourceMetadata?.resource_name ?? this.authorizationServer.authority; - this._logger = loggerService.createLogger(stringifiedServer, { name: this.label }); + this._logger = loggerService.createLogger(this.id, { name: this.label }); this._disposable = new DisposableStore(); this._disposable.add(this._onDidChangeSessions); const scopedEvent = Event.chain(onDidDynamicAuthProviderTokensChange.event, $ => $ @@ -299,7 +301,7 @@ export class DynamicAuthProvider implements vscode.AuthenticationProvider { this._tokenStore = this._disposable.add(new TokenStore( { onDidChange: scopedEvent, - set: (tokens) => _proxy.$setSessionsForDynamicAuthProvider(stringifiedServer, this.clientId, tokens), + set: (tokens) => _proxy.$setSessionsForDynamicAuthProvider(this.id, this.clientId, tokens), }, initialTokens, this._logger