@@ -18,7 +18,7 @@ if (process.env.PROD) {
1818}
1919
2020let mainWindow ;
21- let authToken ;
21+ let authCode ;
2222let authResponse ;
2323
2424function logEverywhere ( ...toBeLogged ) {
@@ -34,37 +34,41 @@ const deeplink = new Deeplink({ app, mainWindow, protocol, isDev });
3434
3535function getSlackAuth ( ) {
3636 const authData = {
37- code : authToken ,
38- client_secret : clientSecret ,
3937 client_id : clientId ,
38+ client_secret : clientSecret ,
39+ code : authCode ,
4040 redirect_uri : 'overvue://slack'
4141 }
42-
42+
4343 const request = net . request ( {
4444 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 ,
4650 headers : {
4751 'Content-Type' : 'application/x-www-form-urlencoded' ,
4852 // 'Content-Length': authData.length
4953 }
5054 } )
5155
52-
5356 request . on ( 'response' , ( response ) => {
54- authResponse = JSON . parse ( response )
57+ logEverywhere ( 'RESPONSE RECEIVED SON' )
58+ JSON . parse ( response )
5559 . then ( data => {
5660 logEverywhere ( 'response with token: ' )
57- logEverywhere ( authResponse )
58- mainWindow . webContents . send ( 'tokenReceived' , authResponse )
61+ logEverywhere ( response )
62+ mainWindow . webContents . send ( 'tokenReceived' , response )
5963 } )
60- } )
61- request . end ( )
64+ } )
65+ request . end ( )
6266}
6367
6468function getSlackToken ( ) {
65- deeplink . on ( "received" , link => {
69+ return deeplink . on ( "received" , link => {
6670 logEverywhere ( 'auth worked here link: ' , link )
67- authToken = link . split ( '=' ) [ 1 ]
71+ authCode = link . split ( '=' ) [ 1 ]
6872 getSlackAuth ( )
6973 } ) ;
7074}
0 commit comments