extensions/github-authentication/src/githubServer.ts/GitHubServer/exchangeCodeForToken
class GitHubServer:	private exchangeCodeForToken: (scopes: string) => PromiseAdapter<vscode.Uri, string> =
		(scopes) => async (uri, resolve, reject) => {
			Logger.info('Exchanging code for token...');
			const query = parseQuery(uri);
			const code = query.code;

			const acceptedStates = this._pendingStates.get(scopes) || [];
			if (!acceptedStates.includes(query.state)) {
				reject('Received mismatched state');
				return;
			}

			const url = `https://${AUTH_RELAY_SERVER}/token?code=${code}&state=${query.state}`;

			// TODO@joao: remove
			if (query.nocors) {
				try {
					const json: any = await vscode.commands.executeCommand('_workbench.fetchJSON', url, 'POST');
					Logger.info('Token exchange success!');
					resolve(json.access_token);
				} catch (err) {
					reject(err);
				}
			} else {
				try {
					const result = await fetch(url, {
						method: 'POST',
						headers: {
							Accept: 'application/json'
						}
					});

					if (result.ok) {
						const json = await result.json();
						Logger.info('Token exchange success!');
						resolve(json.access_token);
					} else {
						reject(result.statusText);
					}
				} catch (ex) {
					reject(ex);
				}
			}
		};