· 7 years ago · Aug 30, 2018, 10:30 PM
1app.get('/auth', function(req, res){
2 if (!req.query.code) { // access denied
3 return;
4 }
5 var data = {form: {
6 client_id: process.env.SLACK_CLIENT_ID,
7 client_secret: process.env.SLACK_CLIENT_SECRET,
8 code: req.query.code
9 }};
10 request.post('https://slack.com/api/oauth.access', data, function (error, response, body) {
11 if (!error && response.statusCode == 200) {
12 // Get an auth token
13 let oauthToken = JSON.parse(body).access_token;
14 // OAuth done- redirect the user to wherever
15 res.redirect(__dirname + "/public/success.html");
16 }
17 })
18});