in vscode/qodana/src/core/auth/AuthorizingImpl.ts [86:109]
async makeOAuthRequest(authzUrl: string, server: http.Server, port: number): Promise<string> {
return new Promise((resolve, reject) => {
// generate random string of 32 characters
let randomString = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
vscode.env.openExternal(vscode.Uri.parse(this.constructOAuthURL(authzUrl, port, randomString)));
server.on('request', (req: http.IncomingMessage, res: http.ServerResponse) => {
const reqUrl = new URL(`http://${req.headers.host}${req.url}`);
if (reqUrl.pathname === '/api/qodana/oauth/authorization_code/') {
const code = reqUrl.searchParams.get('code');
if (code) {
resolve(code);
} else {
telemetry.errorReceived('#makeOAuthRequest no code');
reject();
}
}
// redirect to the page with the message
/* eslint-disable @typescript-eslint/naming-convention */
res.writeHead(302, {'Location': `${this.environment.frontendUrl}/ideauth`});
res.end();
});
});
}