src/vs/workbench/api/browser/mainThreadAuthentication.ts/MainThreadAuthentication/$getSession
class MainThreadAuthentication:	async $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: { createIfNone: boolean, clearSessionPreference: boolean }): Promise<modes.AuthenticationSession | undefined> {
		const sessions = await this.authenticationService.getSessions(providerId, scopes, true);

		const silent = !options.createIfNone;
		let session: modes.AuthenticationSession | undefined;
		if (sessions.length) {
			if (!this.authenticationService.supportsMultipleAccounts(providerId)) {
				session = sessions[0];
				const allowed = this.authenticationService.isAccessAllowed(providerId, session.account.label, extensionId);
				if (!allowed) {
					if (!silent) {
						const didAcceptPrompt = await this.authenticationService.showGetSessionPrompt(providerId, session.account.label, extensionId, extensionName);
						if (!didAcceptPrompt) {
							throw new Error('User did not consent to login.');
						}
					} else if (allowed !== false) {
						this.authenticationService.requestSessionAccess(providerId, extensionId, extensionName, scopes, [session]);
						return undefined;
					} else {
						return undefined;
					}
				}
			} else {
				return this.selectSession(providerId, extensionId, extensionName, scopes, sessions, !!options.clearSessionPreference, silent);
			}
		} else {
			if (!silent) {
				const providerName = await this.authenticationService.getLabel(providerId);
				const isAllowed = await this.loginPrompt(providerName, extensionName);
				if (!isAllowed) {
					throw new Error('User did not consent to login.');
				}

				session = await this.authenticationService.createSession(providerId, scopes, true);
				await this.setTrustedExtensionAndAccountPreference(providerId, session.account.label, extensionId, extensionName, session.id);
			} else {
				await this.authenticationService.requestNewSession(providerId, scopes, extensionId, extensionName);
			}
		}

		if (session) {
			addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
		}

		return session;
	}