in vscode/qodana/src/core/auth/AuthorizedImpl.ts [57:81]
async getToken(): Promise<string | undefined> {
try {
// we need to fetch current auth state
const authState = await Auth.getAuthState(this.context);
// if we are unauthorized, we need to authorize
if (authState instanceof Unauthorized) {
await this.logOut();
return undefined;
} else if (authState instanceof TokenExpired) {
let token = await this.handleTokenExpiredState();
if (token === undefined) {
await this.logOut();
}
return token;
} else if (authState instanceof TokenPresent) {
// get data
return authState.token;
}
} catch (error) {
vscode.window.showErrorMessage(`${FAILED_TO_AUTHENTICATE} ${error}`);
telemetry.errorReceived('#getTokenToCloud exception');
await this.logOut();
return undefined;
}
}