in vscode/qodana/src/core/auth/AuthorizingImpl.ts [26:56]
async startOauth() : Promise<Authorized | NotAuthorized> {
// authorize
let notAuthorized = new NotAuthorizedImpl(this.context, this.stateEmitter);
try {
let code = await this.getCodeFromOAuth();
if (!code) {
telemetry.errorReceived('#handleUnauthorizedState no code');
this.stateEmitter.fire(notAuthorized);
return notAuthorized;
}
// do a post request to get token, refresh token and expires
let auth = await qodanaCloudUnauthorizedApi(this.environment).getOauthToken(code);
if (!auth) {
vscode.window.showErrorMessage(FAILED_TO_OBTAIN_TOKEN);
telemetry.errorReceived('#handleUnauthorizedState no auth');
this.stateEmitter.fire(notAuthorized);
return notAuthorized;
}
let userInfo = await qodanaCloudUserApi(this.environment, async () => {
return auth?.access;
}).getUserInfo();
let newState = await AuthorizedImpl.create(this.context, this.stateEmitter, this.environment, auth, userInfo);
this.stateEmitter.fire(newState);
return newState;
} catch (error) {
this.stateEmitter.fire(notAuthorized);
telemetry.loginFailed();
return notAuthorized;
}
}