mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
add additional logging around github auth
This commit is contained in:
parent
c4cde2147a
commit
4a011b5297
|
@ -46,7 +46,11 @@ export class Keychain {
|
|||
|
||||
async getToken(): Promise<string | null | undefined> {
|
||||
try {
|
||||
return await this.context.secrets.get(this.serviceId);
|
||||
const secret = await this.context.secrets.get(this.serviceId);
|
||||
if (secret && secret !== '[]') {
|
||||
Logger.trace('Token acquired from secret storage.');
|
||||
}
|
||||
return secret;
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
Logger.error(`Getting token failed: ${e}`);
|
||||
|
@ -73,6 +77,7 @@ export class Keychain {
|
|||
|
||||
const oldValue = await keytar.getPassword(`${vscode.env.uriScheme}-github.login`, 'account');
|
||||
if (oldValue) {
|
||||
Logger.trace('Attempting to migrate from keytar to secret store...');
|
||||
await this.setToken(oldValue);
|
||||
await keytar.deletePassword(`${vscode.env.uriScheme}-github.login`, 'account');
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ class Log {
|
|||
return data.toString();
|
||||
}
|
||||
|
||||
public trace(message: string, data?: any): void {
|
||||
this.logLevel('Trace', message, data);
|
||||
}
|
||||
|
||||
public info(message: string, data?: any): void {
|
||||
this.logLevel('Info', message, data);
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
|
|||
try {
|
||||
await this._githubServer.getUserInfo(session.accessToken);
|
||||
this.afterTokenLoad(session.accessToken);
|
||||
Logger.info(`Verified sesion with the following scopes: ${session.scopes}`);
|
||||
verifiedSessions.push(session);
|
||||
} catch (e) {
|
||||
// Remove sessions that return unauthorized response
|
||||
|
@ -156,6 +157,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
|
|||
userInfo = await this._githubServer.getUserInfo(session.accessToken);
|
||||
}
|
||||
|
||||
Logger.trace(`Read the following session from the keychain with the following scopes: ${session.scopes}`);
|
||||
return {
|
||||
id: session.id,
|
||||
account: {
|
||||
|
|
|
@ -20,6 +20,7 @@ const AUTH_RELAY_SERVER = 'vscode-auth.github.com';
|
|||
|
||||
class UriEventHandler extends vscode.EventEmitter<vscode.Uri> implements vscode.UriHandler {
|
||||
public handleUri(uri: vscode.Uri) {
|
||||
Logger.trace('Handling Uri...');
|
||||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ export class GitHubServer {
|
|||
}
|
||||
|
||||
public async login(scopes: string): Promise<string> {
|
||||
Logger.info('Logging in...');
|
||||
Logger.info(`Logging in for the following scopes: ${scopes}`);
|
||||
this.updateStatusBarItem(true);
|
||||
|
||||
const state = uuid();
|
||||
|
|
Loading…
Reference in a new issue