-
Notifications
You must be signed in to change notification settings - Fork 7
/
api.js
46 lines (40 loc) · 1.65 KB
/
api.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
41
42
43
44
45
46
///////////////////////////////////////////////////////////////////
// Copyright (c) 2014 Autodesk, Inc. All rights reserved
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
///////////////////////////////////////////////////////////////////
var CONSUMER_KEY = process.env.CONSUMERKEY || '<replace with your consumer key>';
var CONSUMER_SECRET = process.env.CONSUMERSECRET || '<replace with your consumer secret>';
var BASE_URL = 'https://developer.api.autodesk.com';
var request = require('request');
///////////////////////////////////////////////////////////////////
//
//
///////////////////////////////////////////////////////////////////
exports.getToken = function (req, res) {
var params = {
client_id: CONSUMER_KEY,
client_secret: CONSUMER_SECRET,
grant_type: 'client_credentials'
};
request.post(BASE_URL + '/authentication/v1/authenticate',
{ form: params },
function (error, response, body) {
if (!error && response.statusCode == 200) {
var authResponse = JSON.parse(body);
res.send(authResponse.access_token);
}
}
);
};