Skip to content

Commit 5bcc76b

Browse files
committed
using std naming convention
1 parent 1b7558a commit 5bcc76b

File tree

5 files changed

+59
-64
lines changed

5 files changed

+59
-64
lines changed

README-stg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ get model URNs - as explained in the Setup/Usage Instructions.
4545
```
4646
* Replace the placeholders with your own keys in credentials.js, line #23 and #24 <br />
4747
```
48-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
48+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>';
4949

50-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>';
50+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>';
5151
```
5252
* In file credentials.js line #26, replace the BaseUrl address by the staging server address <br />
5353
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ get model URNs - as explained in the Setup/Usage Instructions.
4141
```
4242
* Replace the placeholders with your own keys in credentials.js, line #23 and #24 <br />
4343
```
44-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
44+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>';
4545

46-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>';
46+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>';
4747
```
4848
* Upload one of your models to your account and get its URN using another workflow sample, for example,
4949
- [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows

credentials_.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1616
// UNINTERRUPTED OR ERROR FREE.
1717
/////////////////////////////////////////////////////////////////////////////////
18+
var credentials ={
1819

19-
var credentials ={} ;
20+
credentials: {
21+
// Replace placeholder below by the Consumer Key and Consumer Secret you got from
22+
// http://developer.autodesk.com/ for the production server
23+
client_id: process.env.CONSUMERKEY || '<replace with your consumer key>',
24+
client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>',
25+
grant_type: 'client_credentials'
26+
},
27+
28+
// If you which to use the Autodesk View & Data API on the staging server, change this url
29+
BaseUrl: 'https://developer.api.autodesk.com',
30+
Version: 'v1'
31+
} ;
2032

21-
// Replace placeholder below by the Consumer Key and Consumer Secret you got from
22-
// http://developer.autodesk.com/ for the production server
23-
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>' ;
24-
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>' ;
25-
26-
// If you which to use the Autodesk View & Data API on the staging server, change this url
27-
credentials.BaseUrl = 'https://developer.api.autodesk.com' ;
33+
credentials.Authentication =credentials.BaseUrl + '/authentication/' + credentials.Version + '/authenticate'
2834

2935
module.exports =credentials ;

package.json

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
{
22
"name": "AdnViewerBasic",
3-
"description": "A basic node.js server sample",
4-
"version": "1.0.0",
5-
"dependencies": {
6-
"serve-favicon": ">= 2.2.0",
7-
"express": ">= 4.12.3",
8-
"request": ">= 2.55.0"
9-
},
10-
"files": [
11-
"LICENSE",
12-
"README.md"
13-
],
14-
"engines": {
15-
"node": ">= 0.10.0"
16-
},
17-
"contributors": [
18-
"Philippe Leefsma <philippe.leefsma@autodesk.com>"
19-
],
20-
"license": "MIT",
21-
"scripts": {
22-
"start": "node server.js"
23-
},
24-
"repository": {
25-
"type": "git",
26-
"url": "https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api.git"
27-
}
3+
"description": "A basic node.js server sample",
4+
"version": "1.0.0",
5+
"dependencies": {
6+
"serve-favicon": ">= 2.2.0",
7+
"express": ">= 4.12.3",
8+
"request": ">= 2.55.0"
9+
},
10+
"files": [
11+
"LICENSE",
12+
"README.md"
13+
],
14+
"engines": {
15+
"node": ">= 0.10.0"
16+
},
17+
"contributors": [
18+
"Philippe Leefsma <philippe.leefsma@autodesk.com>",
19+
"Cyrille Fauvel <cyrille@autodesk.com>"
20+
],
21+
"license": "MIT",
22+
"scripts": {
23+
"start": "node server.js"
24+
},
25+
"repository": {
26+
"type": "git",
27+
"url": "https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api.git"
28+
}
2829
}

routes/api.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,25 @@
1515
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1616
// UNINTERRUPTED OR ERROR FREE.
1717
/////////////////////////////////////////////////////////////////////////////////
18-
var fs = require('fs');
19-
var credentials ;
20-
if ( !fs.existsSync ('credentials.js') ) {
21-
console.log ('No credentials.js file present, assuming using CONSUMERKEY & CONSUMERSECRET system variables.') ;
22-
credentials =require('../credentials_') ;
23-
} else {
24-
credentials =require('../credentials') ;
25-
}
26-
var express = require('express');
27-
var request = require('request');
18+
var credentials =(require ('fs').existsSync ('credentials.js') ?
19+
require('../credentials')
20+
: (console.log ('No credentials.js file present, assuming using CONSUMERKEY & CONSUMERSECRET system variables.'), require('../credentials_'))) ;
21+
var express =require ('express') ;
22+
var request =require ('request') ;
2823

29-
var router = express.Router();
24+
var router =express.Router () ;
3025

3126
///////////////////////////////////////////////////////////////////////////////
3227
// Generates access token
3328
///////////////////////////////////////////////////////////////////////////////
34-
router.get('/token', function (req, res) {
35-
var params = {
36-
client_id: credentials.ConsumerKey,
37-
client_secret: credentials.ConsumerSecret,
38-
grant_type: 'client_credentials'
39-
} ;
40-
41-
request.post(
42-
credentials.BaseUrl + '/authentication/v1/authenticate',
43-
{ form: params },
29+
router.get ('/token', function (req, res) {
30+
request.post (
31+
credentials.Authentication,
32+
{ form: credentials.credentials },
4433
function (error, response, body) {
45-
if (!error && response.statusCode == 200) {
46-
res.send(body);
47-
}
48-
});
49-
});
34+
if ( !error && response.statusCode == 200 )
35+
res.send (body) ;
36+
}) ;
37+
}) ;
5038

51-
module.exports = router;
39+
module.exports =router ;

0 commit comments

Comments
 (0)