-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
42 lines (30 loc) · 1006 Bytes
/
server.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
/* EXPRESS */
const express = require('express');
const app = express();
const cors = require('cors');
app.use(cors({
origin:'http://localhost:3000'
}));
var access_token = "";
const port = 2400;
app.listen(port , () => console.log('App listening on port ' + port));
const axios = require('axios')
const clientID = '0661798dd8b17b1f2412'
const clientSecret = '76c355ce64ad47d96ff2555ae90e37542a9fcba6'
// Function to authorize user's github
app.get('/authenticate/:code', (req, res) => {
const requestToken=req.params.code;
console.log(req.query);
axios({
method: 'post',
url: `https://github.com/login/oauth/access_token?client_id=${clientID}&client_secret=${clientSecret}&code=${requestToken}`,
// Set the content type header, so that we get the response in JSON
headers: {
accept: 'application/json'
}
}).then((response) => {
access_token = response.data.access_token
console.log(response.data)
res.send({token:access_token});
})
})