extensions/microsoft-authentication/src/authServer.ts/callback
async function callback(nonce: string, reqUrl: url.Url): Promise<string> {
	const query = reqUrl.query;
	if (!query || typeof query === 'string') {
		throw new Error('No query received.');
	}

	let error = query.error_description || query.error;

	if (!error) {
		const state = (query.state as string) || '';
		const receivedNonce = (state.split(',')[1] || '').replace(/ /g, '+');
		if (receivedNonce !== nonce) {
			error = 'Nonce does not match.';
		}
	}

	const code = query.code as string;
	if (!error && code) {
		return code;
	}

	throw new Error((error as string) || 'No code received.');
}