forked from QasimWani/LeetHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth2.js
41 lines (36 loc) · 1.1 KB
/
oauth2.js
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
// eslint-disable-next-line no-unused-vars
const oAuth2 = {
/**
* Initialize
*/
init() {
this.KEY = 'leethub_token';
this.ACCESS_TOKEN_URL =
'https://github.com/login/oauth/access_token';
this.AUTHORIZATION_URL =
'https://github.com/login/oauth/authorize';
this.CLIENT_ID = 'beb4f0aa19ab8faf5004';
this.CLIENT_SECRET = '843f835609c7ef02ef0f2f1645bc49514c0e65a6';
this.REDIRECT_URL = 'https://github.com/'; // for example, https://github.com
this.SCOPES = ['repo'];
},
/**
* Begin
*/
begin() {
this.init(); // secure token params.
let url = `${this.AUTHORIZATION_URL}?client_id=${this.CLIENT_ID}&redirect_uri${this.REDIRECT_URL}&scope=`;
for (let i = 0; i < this.SCOPES.length; i += 1) {
url += this.SCOPES[i];
}
chrome.storage.local.set({ pipe_leethub: true }, () => {
// opening pipe temporarily
chrome.tabs.create({ url, active: true }, function () {
window.close();
chrome.tabs.getCurrent(function (tab) {
chrome.tabs.remove(tab.id, function () {});
});
});
});
},
};