@@ -18,7 +18,7 @@ if (process.env.PROD) {
18
18
}
19
19
20
20
let mainWindow ;
21
- let authToken ;
21
+ let authCode ;
22
22
let authResponse ;
23
23
24
24
function logEverywhere ( ...toBeLogged ) {
@@ -34,37 +34,41 @@ const deeplink = new Deeplink({ app, mainWindow, protocol, isDev });
34
34
35
35
function getSlackAuth ( ) {
36
36
const authData = {
37
- code : authToken ,
38
- client_secret : clientSecret ,
39
37
client_id : clientId ,
38
+ client_secret : clientSecret ,
39
+ code : authCode ,
40
40
redirect_uri : 'overvue://slack'
41
41
}
42
-
42
+
43
43
const request = net . request ( {
44
44
method : 'POST' ,
45
- url : 'https://slack.com/api/openid.connect.token?' + ,
45
+ url : 'https://slack.com/api/openid.connect.token?' +
46
+ 'client_id=' + authData . client_id +
47
+ '&client_secret=' + authData . client_secret +
48
+ '&code=' + authData . authCode +
49
+ '&redirect_uri=' + authData . redirect_uri ,
46
50
headers : {
47
51
'Content-Type' : 'application/x-www-form-urlencoded' ,
48
52
// 'Content-Length': authData.length
49
53
}
50
54
} )
51
55
52
-
53
56
request . on ( 'response' , ( response ) => {
54
- authResponse = JSON . parse ( response )
57
+ logEverywhere ( 'RESPONSE RECEIVED SON' )
58
+ JSON . parse ( response )
55
59
. then ( data => {
56
60
logEverywhere ( 'response with token: ' )
57
- logEverywhere ( authResponse )
58
- mainWindow . webContents . send ( 'tokenReceived' , authResponse )
61
+ logEverywhere ( response )
62
+ mainWindow . webContents . send ( 'tokenReceived' , response )
59
63
} )
60
- } )
61
- request . end ( )
64
+ } )
65
+ request . end ( )
62
66
}
63
67
64
68
function getSlackToken ( ) {
65
- deeplink . on ( "received" , link => {
69
+ return deeplink . on ( "received" , link => {
66
70
logEverywhere ( 'auth worked here link: ' , link )
67
- authToken = link . split ( '=' ) [ 1 ]
71
+ authCode = link . split ( '=' ) [ 1 ]
68
72
getSlackAuth ( )
69
73
} ) ;
70
74
}
0 commit comments