forked from QasimWani/LeetHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoauth2.js
35 lines (31 loc) · 997 Bytes
/
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
// 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 = '0114dd35b156d4729fac';
this.CLIENT_SECRET = 'cfc3301d9745530bf1b31e92528ad9c31fd3f995';
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, redirects to github
chrome.tabs.create({ url, active: true }, function () {});
});
},
};