Skip to content

Commit 0d783d5

Browse files
committed
clientid to consumerkey/secret, plus using system variable
1 parent 4a9a5d7 commit 0d783d5

File tree

6 files changed

+43
-40
lines changed

6 files changed

+43
-40
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 placeholder with your own keys in credentials.js, line #23 and #24 <br />
4747
```
48-
credentials.ClientId = '<replace with your consumer key>';
48+
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
4949

50-
credentials.ClientSecret = '<replace with your consumer secret>';
50+
credentials.ConsumerSecret =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 placeholder with your own keys in credentials.js, line #23 and #24 <br />
4343
```
44-
credentials.ClientId = '<replace with your consumer key>';
44+
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>';
4545

46-
credentials.ClientSecret = '<replace with your consumer secret>';
46+
credentials.ConsumerSecret =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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ var credentials ={} ;
2020

2121
// Replace placeholder below by the Consumer Key and Consumer Secret you got from
2222
// http://developer.autodesk.com/ for the production server
23-
credentials.ClientId ='<replace with your consumer key>' ;
24-
credentials.ClientSecret ='<replace with your consumer secret>' ;
23+
credentials.ConsumerKey =process.env.CONSUMERKEY || '<replace with your consumer key>' ;
24+
credentials.ConsumerSecret =process.env.CONSUMERSECRET || '<replace with your consumer secret>' ;
2525

2626
// If you which to use the Autodesk View & Data API on the staging server, change this url
2727
credentials.BaseUrl = 'https://developer.api.autodesk.com' ;

package.json

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
{
2-
"name": "AdnViewerBasic",
3-
"version": "0.0.0",
4-
"dependencies": {
5-
"aws-sign2": "^0.5.0",
6-
"bl": "^0.9.4",
7-
"caseless": "^0.10.0",
8-
"combine-stream": "0.0.4",
9-
"combined-stream": "0.0.7",
10-
"express": "*",
11-
"forever-agent": "^0.6.1",
12-
"form-data": "^0.2.0",
13-
"har-validator": "^1.6.1",
14-
"hawk": "^2.3.1",
15-
"http-signature": "^0.11.0",
16-
"isstream": "^0.1.2",
17-
"json-stringify-safe": "^5.0.0",
18-
"mime-types": "^2.0.10",
19-
"node-uuid": "^1.4.3",
20-
"oauth-sign": "^0.7.0",
21-
"qs": "^2.4.1",
22-
"request": "*",
23-
"router": "^1.1.0",
24-
"serve-favicon": "*",
25-
"stringstream": "0.0.4",
26-
"tough-cookie": "^0.13.0",
27-
"tunnel-agent": "^0.4.0"
28-
}
2+
"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+
}
2928
}

routes/api.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1616
// UNINTERRUPTED OR ERROR FREE.
1717
/////////////////////////////////////////////////////////////////////////////////
18-
var credentials = require('../credentials');
19-
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+
}
2026
var express = require('express');
2127
var request = require('request');
2228

@@ -27,15 +33,14 @@ var router = express.Router();
2733
///////////////////////////////////////////////////////////////////////////////
2834
router.get('/token', function (req, res) {
2935
var params = {
30-
client_id: credentials.ClientId,
31-
client_secret: credentials.ClientSecret,
36+
client_id: credentials.ConsumerKey,
37+
client_secret: credentials.ConsumerSecret,
3238
grant_type: 'client_credentials'
33-
}
39+
} ;
3440

3541
request.post(
3642
credentials.BaseUrl + '/authentication/v1/authenticate',
3743
{ form: params },
38-
3944
function (error, response, body) {
4045
if (!error && response.statusCode == 200) {
4146
res.send(body);

www/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function onError(error) {
5353
console.log('Error: ' + error);
5454
};
5555

56-
5756
// The following code does not rely on Autodesk.ADN.Toolkit.Viewer.AdnViewerManager
5857
// and uses the Autodesk API directly.
5958
//

0 commit comments

Comments
 (0)