-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (30 loc) · 898 Bytes
/
index.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
var express = require('express');
var request = require('request');
var cors = require('cors');
var app = express();
app.use(cors());
var PORT = process.env.PORT;
var CLIENT_ID = process.env.CLIENT_ID;
var CLIENT_SECRET = process.env.CLIENT_SECRET;
var AUTH_URL = "https://www.iconfinder.com/api/v3/oauth2/token";
// Set the route
app.get('/', function(req, res) {
request.post(AUTH_URL, {
form: {
grant_type:'jwt_bearer',
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET
}
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
delete body.token_type;
res.send(body);
} else {
console.log(error, response, body);
}
});
});
// Bind the app to the PORT
app.listen(PORT, function() {
console.log('Example app listening on port', PORT);
});