-
Notifications
You must be signed in to change notification settings - Fork 0
/
github-authentication-plugin.ts
44 lines (38 loc) · 1.29 KB
/
github-authentication-plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Generated using theia-plugin-generator
*/
import * as theia from '@theia/plugin';
export function start(context: theia.PluginContext) {
let session: theia.AuthenticationSession | undefined;
const onDidChangeSessions = new theia.EventEmitter<theia.AuthenticationProviderAuthenticationSessionsChangeEvent>();
theia.authentication.registerAuthenticationProvider({
id: 'github',
label: 'GitHub',
supportsMultipleAccounts: false,
onDidChangeSessions: onDidChangeSessions.event,
getSessions: async () => {
if (session) {
return [session];
} else {
return [];
}
},
login: async (scopeList: string[]) => {
session = {
id: 'github-session',
accessToken: 'paste the github token here',
account: { label: 'githubUser', id: 'githubUserId' },
scopes: scopeList
};
onDidChangeSessions.fire({ added: [session.id], removed: [], changed: [] });
return session;
},
logout: async (id: string) => {
session = undefined;
onDidChangeSessions.fire({ added: [], removed: [id], changed: [] });
}
}
);
}
export function stop() {
}