mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 09:35:37 -05:00
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
import { GitHubAuthenticationProvider, onDidChangeSessions } from './github';
|
|
import { uriHandler } from './githubServer';
|
|
import Logger from './common/logger';
|
|
|
|
export async function activate(context: vscode.ExtensionContext) {
|
|
|
|
context.subscriptions.push(vscode.window.registerUriHandler(uriHandler));
|
|
const loginService = new GitHubAuthenticationProvider();
|
|
|
|
await loginService.initialize();
|
|
|
|
vscode.authentication.registerAuthenticationProvider({
|
|
id: 'github',
|
|
displayName: 'GitHub',
|
|
onDidChangeSessions: onDidChangeSessions.event,
|
|
getSessions: () => Promise.resolve(loginService.sessions),
|
|
login: async (scopeList: string[]) => {
|
|
try {
|
|
const session = await loginService.login(scopeList.join(' '));
|
|
Logger.info('Login success!');
|
|
onDidChangeSessions.fire({ added: [session.id], removed: [], changed: [] });
|
|
return session;
|
|
} catch (e) {
|
|
vscode.window.showErrorMessage(`Sign in failed: ${e}`);
|
|
Logger.error(e);
|
|
throw e;
|
|
}
|
|
},
|
|
logout: async (id: string) => {
|
|
await loginService.logout(id);
|
|
onDidChangeSessions.fire({ added: [], removed: [id], changed: [] });
|
|
}
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
// this method is called when your extension is deactivated
|
|
export function deactivate() { }
|