src/vs/workbench/api/browser/mainThreadAuthentication.ts/MainThreadAuthentication/selectSession
class MainThreadAuthentication:	private async selectSession(providerId: string, extensionId: string, extensionName: string, scopes: string[], potentialSessions: readonly modes.AuthenticationSession[], clearSessionPreference: boolean, silent: boolean): Promise<modes.AuthenticationSession | undefined> {
		if (!potentialSessions.length) {
			throw new Error('No potential sessions found');
		}

		if (clearSessionPreference) {
			this.storageService.remove(`${extensionName}-${providerId}`, StorageScope.GLOBAL);
		} else {
			const existingSessionPreference = this.storageService.get(`${extensionName}-${providerId}`, StorageScope.GLOBAL);
			if (existingSessionPreference) {
				const matchingSession = potentialSessions.find(session => session.id === existingSessionPreference);
				if (matchingSession) {
					const allowed = this.authenticationService.isAccessAllowed(providerId, matchingSession.account.label, extensionId);
					if (!allowed) {
						if (!silent) {
							const didAcceptPrompt = await this.authenticationService.showGetSessionPrompt(providerId, matchingSession.account.label, extensionId, extensionName);
							if (!didAcceptPrompt) {
								throw new Error('User did not consent to login.');
							}
						} else {
							this.authenticationService.requestSessionAccess(providerId, extensionId, extensionName, scopes, potentialSessions);
							return undefined;
						}
					}

					return matchingSession;
				}
			}
		}

		if (silent) {
			this.authenticationService.requestSessionAccess(providerId, extensionId, extensionName, scopes, potentialSessions);
			return undefined;
		}

		return this.authenticationService.selectSession(providerId, extensionId, extensionName, scopes, potentialSessions);
	}