From b5e713d7df71b2f32ae84d0518132f0ed30f511c Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 10:11:38 +0800 Subject: [PATCH 01/38] edit gitignore to include credentials --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 410bdf4..7ec8a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ node_modules .lock-wscript # API credentials file -credentials.js +# credentials.js # webstorm project files .idea From 1d3dfc364b44e2ff6c3f8a1c5f9be2d5a7273526 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 10:16:22 +0800 Subject: [PATCH 02/38] add credential.js --- credentials.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 credentials.js diff --git a/credentials.js b/credentials.js new file mode 100644 index 0000000..7faa047 --- /dev/null +++ b/credentials.js @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////// +// Copyright (c) Autodesk, Inc. All rights reserved +// Written by Philippe Leefsma 2014 - ADN/Developer Technical Services +// +// 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 credentials ={} ; + +// Replace placeholder below by the Consumer Key and Consumer Secret you got from +// http://developer.autodesk.com/ for the production server +credentials.ClientId ='' ; +credentials.ClientSecret ='' ; + +// If you which to use the Autodesk View & Data API on the staging server, change this url +credentials.BaseUrl = 'https://developer.api.autodesk.com' ; + +module.exports =credentials ; From 82b66be1bf142661432383030e6a975b16ac2857 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 10:34:14 +0800 Subject: [PATCH 03/38] a running version --- www/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/index.js b/www/index.js index 7274ef9..a157e3c 100644 --- a/www/index.js +++ b/www/index.js @@ -15,7 +15,7 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// -var defaultUrn = ''; +var defaultUrn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWwtYXMtYS1zZXJ2aWNlMjAxNTAxMjYvRHJpbGwuZHdmeA=='; $(document).ready(function () { var tokenurl = 'http://' + window.location.host + '/api/token'; From 60d0d866ef730114027065d95926d64c45967ad0 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 11:10:12 +0800 Subject: [PATCH 04/38] add credential keys --- credentials.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/credentials.js b/credentials.js index 7faa047..7dd1aaf 100644 --- a/credentials.js +++ b/credentials.js @@ -20,8 +20,8 @@ var credentials ={} ; // Replace placeholder below by the Consumer Key and Consumer Secret you got from // http://developer.autodesk.com/ for the production server -credentials.ClientId ='' ; -credentials.ClientSecret ='' ; +credentials.ClientId ='mvMpJWBGyBuGpVycB77FFgP45T4dBycD' ; +credentials.ClientSecret ='9hL2KEgGdAcabpW0' ; // If you which to use the Autodesk View & Data API on the staging server, change this url credentials.BaseUrl = 'https://developer.api.autodesk.com' ; From 357752a50f659c7870ded835d872e0242c82326b Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 11:14:02 +0800 Subject: [PATCH 05/38] another minor change --- credentials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/credentials.js b/credentials.js index 7dd1aaf..80d7da4 100644 --- a/credentials.js +++ b/credentials.js @@ -13,7 +13,7 @@ // 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. +// UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// var credentials ={} ; From b3a0336afff849885f607b191d58c8c039fa3ece Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 11:54:15 +0800 Subject: [PATCH 06/38] use conf vars --- routes/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/api.js b/routes/api.js index 408f063..b9fe2b2 100644 --- a/routes/api.js +++ b/routes/api.js @@ -27,8 +27,8 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: credentials.ClientId, - client_secret: credentials.ClientSecret, + client_id: process.env.ClientId; //credentials.ClientId, + client_secret: process.env.ClientSecret;//credentials.ClientSecret, grant_type: 'client_credentials' } From a31a52e6af38c673153189be4823ed2ae091301f Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 11:55:36 +0800 Subject: [PATCH 07/38] bug fix --- routes/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/api.js b/routes/api.js index b9fe2b2..f945014 100644 --- a/routes/api.js +++ b/routes/api.js @@ -27,8 +27,8 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: process.env.ClientId; //credentials.ClientId, - client_secret: process.env.ClientSecret;//credentials.ClientSecret, + client_id: process.env.ClientId, //credentials.ClientId, + client_secret: process.env.ClientSecret,//credentials.ClientSecret, grant_type: 'client_credentials' } From 50f6deb2604541047c59872d064ac2784fc13b0d Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 11:58:21 +0800 Subject: [PATCH 08/38] bug fix --- routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index f945014..0284912 100644 --- a/routes/api.js +++ b/routes/api.js @@ -27,7 +27,7 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: process.env.ClientId, //credentials.ClientId, + client_id: process.env.ClientId, //credentials.ClientId, client_secret: process.env.ClientSecret,//credentials.ClientSecret, grant_type: 'client_credentials' } From 552f4b0ce1319d8c1bc5db6e361d47fa95b39073 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 12:00:54 +0800 Subject: [PATCH 09/38] bug fix --- routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index 0284912..5de8dd1 100644 --- a/routes/api.js +++ b/routes/api.js @@ -15,7 +15,7 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// -var credentials = require('../credentials'); +//var credentials = require('../credentials'); var express = require('express'); var request = require('request'); From 140583f319db43a7e52b20ae2d9868a2c373edf2 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 12:43:00 +0800 Subject: [PATCH 10/38] bug fix --- routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index 5de8dd1..a8f431f 100644 --- a/routes/api.js +++ b/routes/api.js @@ -33,7 +33,7 @@ router.get('/token', function (req, res) { } request.post( - credentials.BaseUrl + '/authentication/v1/authenticate', + process.env.BaseUrl + '/authentication/v1/authenticate', { form: params }, function (error, response, body) { From c5011aa31d50c077129cc630da06130b42b1dbc1 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 12:46:05 +0800 Subject: [PATCH 11/38] clean up --- credentials.js | 29 ----------------------------- routes/api.js | 5 ++--- 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 credentials.js diff --git a/credentials.js b/credentials.js deleted file mode 100644 index 80d7da4..0000000 --- a/credentials.js +++ /dev/null @@ -1,29 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// Copyright (c) Autodesk, Inc. All rights reserved -// Written by Philippe Leefsma 2014 - ADN/Developer Technical Services -// -// 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 credentials ={} ; - -// Replace placeholder below by the Consumer Key and Consumer Secret you got from -// http://developer.autodesk.com/ for the production server -credentials.ClientId ='mvMpJWBGyBuGpVycB77FFgP45T4dBycD' ; -credentials.ClientSecret ='9hL2KEgGdAcabpW0' ; - -// If you which to use the Autodesk View & Data API on the staging server, change this url -credentials.BaseUrl = 'https://developer.api.autodesk.com' ; - -module.exports =credentials ; diff --git a/routes/api.js b/routes/api.js index a8f431f..aad4245 100644 --- a/routes/api.js +++ b/routes/api.js @@ -15,7 +15,6 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// -//var credentials = require('../credentials'); var express = require('express'); var request = require('request'); @@ -27,8 +26,8 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: process.env.ClientId, //credentials.ClientId, - client_secret: process.env.ClientSecret,//credentials.ClientSecret, + client_id: process.env.ClientId, + client_secret: process.env.ClientSecret, grant_type: 'client_credentials' } From d400c5492ebb6cde1841d1ccbbe782a702716bd1 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 16:05:04 +0800 Subject: [PATCH 12/38] credential at run time --- credentials_.js | 29 ----------------------------- routes/api.js | 4 ++-- run.bat | 4 ++++ run.sh | 4 ++++ server.js | 1 + www/index.js | 2 +- 6 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 credentials_.js create mode 100644 run.bat create mode 100755 run.sh diff --git a/credentials_.js b/credentials_.js deleted file mode 100644 index 7faa047..0000000 --- a/credentials_.js +++ /dev/null @@ -1,29 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// Copyright (c) Autodesk, Inc. All rights reserved -// Written by Philippe Leefsma 2014 - ADN/Developer Technical Services -// -// 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 credentials ={} ; - -// Replace placeholder below by the Consumer Key and Consumer Secret you got from -// http://developer.autodesk.com/ for the production server -credentials.ClientId ='' ; -credentials.ClientSecret ='' ; - -// If you which to use the Autodesk View & Data API on the staging server, change this url -credentials.BaseUrl = 'https://developer.api.autodesk.com' ; - -module.exports =credentials ; diff --git a/routes/api.js b/routes/api.js index aad4245..e168fee 100644 --- a/routes/api.js +++ b/routes/api.js @@ -26,8 +26,8 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: process.env.ClientId, - client_secret: process.env.ClientSecret, + client_id: process.env.ClientId , + client_secret: process.env.ClientSecret, grant_type: 'client_credentials' } diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..113dd83 --- /dev/null +++ b/run.bat @@ -0,0 +1,4 @@ +ClientId= \ +ClientSecret= \ +BaseUrl=https://developer.api.autodesk.com \ +node server.js \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..4d664d4 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +ClientId=replace_with_your_consumer_key \ +ClientSecret=replace_with_your_secret_key \ +BaseUrl=https://developer.api.autodesk.com \ +node server.js \ No newline at end of file diff --git a/server.js b/server.js index 989f4cf..8e6b864 100644 --- a/server.js +++ b/server.js @@ -15,6 +15,7 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// + var favicon = require('serve-favicon'); var api = require('./routes/api'); var express = require('express'); diff --git a/www/index.js b/www/index.js index a157e3c..60b74d7 100644 --- a/www/index.js +++ b/www/index.js @@ -15,7 +15,7 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// -var defaultUrn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWwtYXMtYS1zZXJ2aWNlMjAxNTAxMjYvRHJpbGwuZHdmeA=='; +var defaultUrn = ''; $(document).ready(function () { var tokenurl = 'http://' + window.location.host + '/api/token'; From a086d062007f91dc6c6e716ca015d626f1079063 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 16:09:11 +0800 Subject: [PATCH 13/38] update readme --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 890eed8..cd75e47 100644 --- a/README.md +++ b/README.md @@ -25,32 +25,27 @@ get model URNs - as explained in the Setup/Usage Instructions. ## Setup/Usage Instructions * Apply for your own credentials (API keys) from [http://developer.autodesk.com](http://developer.autodesk.com) -* From the sample root folder, rename or copy the ./credentials_.js file into ./credentials.js
- * Windows
- ``` - copy credentials_.js credentials.js - ``` - * OSX/Linux
- ``` - cp credentials_.js credentials.js - ``` -* Replace the placeholder with your own keys in credentials.js, line #23 and #24
+ +* Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), line + ``` - credentials.ClientId = ''; - - credentials.ClientSecret = ''; +ClientId=replace_with_your_consumer_key \ +ClientSecret=replace_with_your_secret_key \ +BaseUrl=https://developer.api.autodesk.com \ +node server.js ``` * Upload one of your models to your account and get its URN using another workflow sample, for example, - [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac - - or this [WEB page](http://javalmvwalkthrough-vq2mmximxb.elasticbeanstalk.com/) + - or this [WEB page](http://models.autodesk.io) * Copy the URN which was generated in the previous step in file /www/index.js at line #18
``` var defaultUrn = ''; ``` * Run the server from the Node.js console, by running the following command:
``` - node server.js + chmod +x run.sh + ./run.sh ``` * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) From 494f36a204d80f968dc229247504c950d43fcbaf Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 20:05:09 +0800 Subject: [PATCH 14/38] Update run.bat --- run.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run.bat b/run.bat index 113dd83..eaca123 100644 --- a/run.bat +++ b/run.bat @@ -1,4 +1,4 @@ -ClientId= \ -ClientSecret= \ -BaseUrl=https://developer.api.autodesk.com \ -node server.js \ No newline at end of file +set ClientId= +set ClientSecret= +set BaseUrl=https://developer.api.autodesk.com +node server.js From 44a6a5bb74f92ce3c73f8dd2210e75268d961115 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 20:08:29 +0800 Subject: [PATCH 15/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd75e47..eb58076 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ get model URNs - as explained in the Setup/Usage Instructions. * Apply for your own credentials (API keys) from [http://developer.autodesk.com](http://developer.autodesk.com) -* Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), line +* Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), ``` ClientId=replace_with_your_consumer_key \ From 4e0bad415de49daee062a966278befdb414048aa Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 20:14:10 +0800 Subject: [PATCH 16/38] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb58076..5cd25ad 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ node server.js ``` * Run the server from the Node.js console, by running the following command:
``` - chmod +x run.sh - ./run.sh + chmod +x run.sh + ./run.sh ``` * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) From 803fe07a528d37e2257d4f6b0e16e10a7bef9509 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Thu, 7 May 2015 20:15:43 +0800 Subject: [PATCH 17/38] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5cd25ad..21ba3c9 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ node server.js ``` * Run the server from the Node.js console, by running the following command:
``` - chmod +x run.sh - ./run.sh +chmod +x run.sh +./run.sh ``` * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) From 2e31662c3ef5e05cc7ad88bbf1cfa016b2b060ae Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:25:30 +0800 Subject: [PATCH 18/38] update readme --- README-option.md | 12 +----------- README-stg.md | 40 ++++++++++++++++++---------------------- README.md | 24 ++++++++++++++---------- 3 files changed, 33 insertions(+), 43 deletions(-) diff --git a/README-option.md b/README-option.md index 6396a6a..1de7cfd 100644 --- a/README-option.md +++ b/README-option.md @@ -24,17 +24,7 @@ get model URNs - as explained in the Setup/Usage Instructions. ## Setup/Usage Instructions -* From the sample root folder, rename or copy the ./credentials_.js file into ./credentials.js
- * Windows
- ``` - copy credentials_.js credentials.js - ``` - * OSX/Linux
- ``` - cp credentials_.js credentials.js - ``` -* The [upload tool](http://still-spire-1606.herokuapp.com) provides some existing models. Choose any one of them, or upload one of your own - models with [upload tool](http://still-spire-1606.herokuapp.com). The [upload tool](http://still-spire-1606.herokuapp.com) will generate a URN of the model that you need later. +* The [upload tool](http://still-spire-1606.herokuapp.com) provides some existing models. Choose any one of them, or upload one of your own models with [upload tool](http://still-spire-1606.herokuapp.com). The [upload tool](http://still-spire-1606.herokuapp.com) will generate a URN of the model that you need later. * Copy the URN which was generated in the previous step in file /www/index.js at line #18
``` var defaultUrn = ''; diff --git a/README-stg.md b/README-stg.md index 56bacc1..2869cc3 100644 --- a/README-stg.md +++ b/README-stg.md @@ -34,29 +34,20 @@ get model URNs - as explained in the Setup/Usage Instructions. ## Setup/Usage Instructions * Apply for your own credentials (API keys) from [http://developer-stg.autodesk.com](http://developer-stg.autodesk.com) -* From the sample root folder, rename or copy the ./credentials_.js file into ./credentials.js
- * Windows
- ``` - copy credentials_.js credentials.js - ``` - * OSX/Linux
- ``` - cp credentials_.js credentials.js - ``` -* Replace the placeholder with your own keys in credentials.js, line #23 and #24
- ``` - credentials.ClientId = ''; - - credentials.ClientSecret = ''; - ``` -* In file credentials.js line #26, replace the BaseUrl address by the staging server address
+* Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), + ``` - credentials.BaseUrl = 'https://developer-stg.api.autodesk.com' ; +ClientId=replace_with_your_consumer_key \ +ClientSecret=replace_with_your_secret_key \ +BaseUrl=https://developer-stg.api.autodesk.com \ +node server.js ``` + * Upload one of your models to your account and get its URN using another workflow sample, for example, - [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac - - or this [WEB page](http://javalmvwalkthrough-vq2mmximxb.elasticbeanstalk.com/) + Please note that you also need to change the base url to https://developer-stg.api.autodesk.com and replace your consumer key and secret on staging. + * Copy the URN which was generated in the previous step in file /www/index.js at line #18
``` var defaultUrn = ''; @@ -68,10 +59,15 @@ get model URNs - as explained in the Setup/Usage Instructions. ``` * In file /www/index.js, comment out line #23, and uncomment line #24 -* Run the server from the Node.js console, by running the following command:
- ``` - node server.js - ``` +* Run the server from the Node.js console, by running the following command(For Mac): + + chmod +x run.sh + ./run.sh + + For windows, run the "run.bat" from command window + + run.bat + * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) diff --git a/README.md b/README.md index 21ba3c9..d76de25 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,19 @@ node server.js - [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac - or this [WEB page](http://models.autodesk.io) -* Copy the URN which was generated in the previous step in file /www/index.js at line #18
- ``` - var defaultUrn = ''; - ``` -* Run the server from the Node.js console, by running the following command:
- ``` -chmod +x run.sh -./run.sh - ``` +* Copy the URN which was generated in the previous step in file /www/index.js at line #18 + + var defaultUrn = ''; + +* Run the server from the Node.js console, by running the following command(For Mac): + + chmod +x run.sh + ./run.sh + + For windows, run the "run.bat" from command window + + run.bat + * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) @@ -60,7 +64,7 @@ You can work with production or staging Autodesk View and Data environments. By * Instructions to setup this sample to use the Autodesk View & Data staging server are [here](https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api/blob/master/README-stg.md) -You can also use someone else credentials to view models using this sample. +If you are in a hurry, do not want to translate your own models, you can try our prepared models. You need use the access token generated from someone else credentials to view models using this sample. * Instructions to setup this sample using someone else credentials are available [here](https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api/blob/master/README-option.md) From c347374abb75c8809f6087390c3f37569bff75e6 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:27:19 +0800 Subject: [PATCH 19/38] update readme formating --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d76de25..5f8dc51 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ node server.js * Run the server from the Node.js console, by running the following command(For Mac): - chmod +x run.sh - ./run.sh + $ chmod +x run.sh + $ ./run.sh For windows, run the "run.bat" from command window From 38d9a43b1d2b8088c298ebd84d0205cda9ad9c8d Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:28:35 +0800 Subject: [PATCH 20/38] formating --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f8dc51..e881592 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ node server.js - or this [WEB page](http://models.autodesk.io) * Copy the URN which was generated in the previous step in file /www/index.js at line #18 - var defaultUrn = ''; + var defaultUrn = 'replace with your encoded urn'; * Run the server from the Node.js console, by running the following command(For Mac): From 4bb694597971caed5051f51fa87c83aab13c0414 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:30:26 +0800 Subject: [PATCH 21/38] formating --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e881592..e29ba38 100644 --- a/README.md +++ b/README.md @@ -39,18 +39,18 @@ node server.js - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac - or this [WEB page](http://models.autodesk.io) * Copy the URN which was generated in the previous step in file /www/index.js at line #18 - + ``` var defaultUrn = 'replace with your encoded urn'; - + ``` * Run the server from the Node.js console, by running the following command(For Mac): - + ``` $ chmod +x run.sh $ ./run.sh - + ``` For windows, run the "run.bat" from command window - + ``` run.bat - + ``` * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) From 8b9ccd0860e5c40c5e325c714f407bd0ed5bd460 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:32:20 +0800 Subject: [PATCH 22/38] formarting --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e29ba38..c6f3aaf 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,20 @@ node server.js - [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac - or this [WEB page](http://models.autodesk.io) -* Copy the URN which was generated in the previous step in file /www/index.js at line #18 +* Copy the URN which was generated in the previous step in file /www/index.js at line #18 + ``` var defaultUrn = 'replace with your encoded urn'; ``` -* Run the server from the Node.js console, by running the following command(For Mac): +* Run the server from the Node.js console, by running the following command(For Mac): + ``` $ chmod +x run.sh $ ./run.sh ``` + For windows, run the "run.bat" from command window + ``` run.bat ``` From 70447da751000dd82ab3f9f61348a5b137cf05bb Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:52:45 +0800 Subject: [PATCH 23/38] formating --- README-stg.md | 16 ++++++++++------ README.md | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README-stg.md b/README-stg.md index 2869cc3..30aa6bf 100644 --- a/README-stg.md +++ b/README-stg.md @@ -59,15 +59,19 @@ node server.js ``` * In file /www/index.js, comment out line #23, and uncomment line #24 -* Run the server from the Node.js console, by running the following command(For Mac): - - chmod +x run.sh - ./run.sh - +* Run the server from the Node.js console, by running the following command(For Mac): + + ``` + $ chmod +x run.sh + $ ./run.sh + ``` + For windows, run the "run.bat" from command window + ``` run.bat - + ``` + * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) diff --git a/README.md b/README.md index c6f3aaf..4f51073 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,12 @@ By default, the project is setup with the production server, and use your own cr You can work with production or staging Autodesk View and Data environments. By default, the project is setup with the production server. -* Instructions to setup this sample to use the Autodesk View & Data staging server are [here](https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api/blob/master/README-stg.md) +* Instructions to setup this sample to use the Autodesk View & Data staging server are [here](README-stg.md) If you are in a hurry, do not want to translate your own models, you can try our prepared models. You need use the access token generated from someone else credentials to view models using this sample. -* Instructions to setup this sample using someone else credentials are available [here](https://github.com/Developer-Autodesk/workflow-node.js-view.and.data.api/blob/master/README-option.md) +* Instructions to setup this sample using someone else credentials are available [here](README-option.md) ## License From fc7ffb91305a5f8bd7575d75361a3158a4578f5b Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 11:56:46 +0800 Subject: [PATCH 24/38] formating --- README-stg.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README-stg.md b/README-stg.md index 30aa6bf..731f296 100644 --- a/README-stg.md +++ b/README-stg.md @@ -45,7 +45,8 @@ node server.js * Upload one of your models to your account and get its URN using another workflow sample, for example, - [this workflow sample in .Net WPF application](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) if you are using windows - - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac + - or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac. + Please note that you also need to change the base url to https://developer-stg.api.autodesk.com and replace your consumer key and secret on staging. * Copy the URN which was generated in the previous step in file /www/index.js at line #18
@@ -71,7 +72,7 @@ node server.js ``` run.bat ``` - + * Connect to you local server using a WebGL-compatible browser: [http://localhost:3000/](http://localhost:3000/) From ece0b66511686e64ec31592f83622321e98e1f2a Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Fri, 8 May 2015 12:24:35 +0800 Subject: [PATCH 25/38] renaming --- README-stg.md | 4 ++-- README.md | 4 ++-- routes/api.js | 4 ++-- run.bat | 2 +- run.sh | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README-stg.md b/README-stg.md index 731f296..485baf3 100644 --- a/README-stg.md +++ b/README-stg.md @@ -37,8 +37,8 @@ get model URNs - as explained in the Setup/Usage Instructions. * Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), ``` -ClientId=replace_with_your_consumer_key \ -ClientSecret=replace_with_your_secret_key \ +ConsumerKey=replace_with_your_consumer_key \ +ConsumerSecret=replace_with_your_secret_key \ BaseUrl=https://developer-stg.api.autodesk.com \ node server.js ``` diff --git a/README.md b/README.md index 4f51073..85a9257 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ get model URNs - as explained in the Setup/Usage Instructions. * Replace the placeholder with your own keys in run.sh(for Mac/Linux) or run.bat(for Windows), ``` -ClientId=replace_with_your_consumer_key \ -ClientSecret=replace_with_your_secret_key \ +ConsumerKey=replace_with_your_consumer_key \ +ConsumerSecret=replace_with_your_secret_key \ BaseUrl=https://developer.api.autodesk.com \ node server.js ``` diff --git a/routes/api.js b/routes/api.js index e168fee..aeb2dfc 100644 --- a/routes/api.js +++ b/routes/api.js @@ -26,8 +26,8 @@ var router = express.Router(); /////////////////////////////////////////////////////////////////////////////// router.get('/token', function (req, res) { var params = { - client_id: process.env.ClientId , - client_secret: process.env.ClientSecret, + client_id: process.env.ConsumerKey , + client_secret: process.env.ConsumerSecret, grant_type: 'client_credentials' } diff --git a/run.bat b/run.bat index eaca123..dd71ec3 100644 --- a/run.bat +++ b/run.bat @@ -1,4 +1,4 @@ -set ClientId= +set ConsumerKey= set ClientSecret= set BaseUrl=https://developer.api.autodesk.com node server.js diff --git a/run.sh b/run.sh index 4d664d4..8ca0615 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -ClientId=replace_with_your_consumer_key \ -ClientSecret=replace_with_your_secret_key \ +ConsumerKey=replace_with_your_consumer_key \ +ConsumerSecret=replace_with_your_secret_key \ BaseUrl=https://developer.api.autodesk.com \ node server.js \ No newline at end of file From 849a8e61b2cd746d9fd7401f5dc26d1d03c3ccbe Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 17:03:25 +0800 Subject: [PATCH 26/38] edit gitignore --- .gitignore | 5 +++-- routes/api.js | 17 +++++++++++++++++ run.bat | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7ec8a6c..ac03711 100644 --- a/.gitignore +++ b/.gitignore @@ -28,8 +28,9 @@ node_modules .lock-wscript # API credentials file -# credentials.js +run.bat +run.sh # webstorm project files .idea -credentials_.js + diff --git a/routes/api.js b/routes/api.js index aeb2dfc..4ea5415 100644 --- a/routes/api.js +++ b/routes/api.js @@ -31,12 +31,29 @@ router.get('/token', function (req, res) { grant_type: 'client_credentials' } + //var thisHost = req.headers.host; + //Console.log(thisHost); + request.post( process.env.BaseUrl + '/authentication/v1/authenticate', { form: params }, function (error, response, body) { if (!error && response.statusCode == 200) { + + // Website you wish to allow to connect + //res.setHeader('Access-Control-Allow-Origin', '*'); + + // Request methods you wish to allow + res.setHeader('Access-Control-Allow-Methods', 'GET'); + + // // Request headers you wish to allow + // res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); + + // // Set to true if you need the website to include cookies in the requests sent + // // to the API (e.g. in case you use sessions) + // res.setHeader('Access-Control-Allow-Credentials', true); + res.send(body); } }); diff --git a/run.bat b/run.bat index dd71ec3..15e7fef 100644 --- a/run.bat +++ b/run.bat @@ -1,4 +1,4 @@ set ConsumerKey= -set ClientSecret= +set ConsumerSecret= set BaseUrl=https://developer.api.autodesk.com node server.js From 469c10600cbdf8c0d21f375a6aa44e998cea4efe Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 17:53:46 +0800 Subject: [PATCH 27/38] secure token --- routes/api.js | 5 ++--- www/index.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/routes/api.js b/routes/api.js index 4ea5415..8d8e75b 100644 --- a/routes/api.js +++ b/routes/api.js @@ -31,8 +31,7 @@ router.get('/token', function (req, res) { grant_type: 'client_credentials' } - //var thisHost = req.headers.host; - //Console.log(thisHost); + var thisHost = req.protocol + '://' + req.get('host'); request.post( process.env.BaseUrl + '/authentication/v1/authenticate', @@ -42,7 +41,7 @@ router.get('/token', function (req, res) { if (!error && response.statusCode == 200) { // Website you wish to allow to connect - //res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Origin', thisHost); // Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET'); diff --git a/www/index.js b/www/index.js index 60b74d7..5e06162 100644 --- a/www/index.js +++ b/www/index.js @@ -15,7 +15,7 @@ // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. ///////////////////////////////////////////////////////////////////////////////// -var defaultUrn = ''; +var defaultUrn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWwyMDE1LTA1LTExLTA5LTE2LTEwLWdlN3B4aXNzNDF0eGRqdHhxa3R4eTN3MWc2emUvUm9ib3RBcm0uZHdmeA=='; $(document).ready(function () { var tokenurl = 'http://' + window.location.host + '/api/token'; From 77e71e99d745d9167bcb878d9c6732daaec6868e Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 19:50:13 +0800 Subject: [PATCH 28/38] hardcode host --- routes/api.js | 16 +++++++++++++++- run.sh | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/routes/api.js b/routes/api.js index 8d8e75b..a22c604 100644 --- a/routes/api.js +++ b/routes/api.js @@ -21,6 +21,18 @@ var request = require('request'); var router = express.Router(); +router.get('/tokenadsk', function (req, res) { + + //steals access token from a360 + request('http://secure-token.herokuapp.com/api/token', + function (error, response, body) { + if (!error && response.statusCode == 200) { + res.send(body); + } + }); +}); + + /////////////////////////////////////////////////////////////////////////////// // Generates access token /////////////////////////////////////////////////////////////////////////////// @@ -31,7 +43,9 @@ router.get('/token', function (req, res) { grant_type: 'client_credentials' } - var thisHost = req.protocol + '://' + req.get('host'); + //var thisHost = req.protocol + '://' + req.get('host'); + var thisHost = 'http://secure-token.herokuapp.com'; + request.post( process.env.BaseUrl + '/authentication/v1/authenticate', diff --git a/run.sh b/run.sh index 8ca0615..fd6584b 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -ConsumerKey=replace_with_your_consumer_key \ -ConsumerSecret=replace_with_your_secret_key \ +ConsumerKey=VAgANZ4aiHITHoGeGLzv0oBtMAlFBeUa \ +ConsumerSecret=9kfkcETJZI4Blre2 \ BaseUrl=https://developer.api.autodesk.com \ node server.js \ No newline at end of file From 04e263245bd8ff1d340479f771769dcae0074e8d Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 19:54:00 +0800 Subject: [PATCH 29/38] registric --- routes/api.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/api.js b/routes/api.js index a22c604..b15e176 100644 --- a/routes/api.js +++ b/routes/api.js @@ -43,8 +43,12 @@ router.get('/token', function (req, res) { grant_type: 'client_credentials' } - //var thisHost = req.protocol + '://' + req.get('host'); - var thisHost = 'http://secure-token.herokuapp.com'; + var thisHost = req.protocol + '://' + req.get('host'); + var appHost = 'http://secure-token.herokuapp.com'; + + if (thisHost != appHost) { + res.send('host restricted.'); + } request.post( From ee0ee16e9fa2506698e1382b59807456b78debcf Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 19:56:47 +0800 Subject: [PATCH 30/38] restrict host --- routes/api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index b15e176..a79bf23 100644 --- a/routes/api.js +++ b/routes/api.js @@ -47,7 +47,10 @@ router.get('/token', function (req, res) { var appHost = 'http://secure-token.herokuapp.com'; if (thisHost != appHost) { - res.send('host restricted.'); + var strMsg = ' request host: ' + thisHost; + strMsg = strMsg + ' app host: ' + appHost; + res.send('host restricted.' + strMsg); + res.end(); } From 10784ce421740ffc877a6efb24cd3309fcf15cb4 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 20:17:44 +0800 Subject: [PATCH 31/38] update --- routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index a79bf23..2a37e6b 100644 --- a/routes/api.js +++ b/routes/api.js @@ -50,7 +50,7 @@ router.get('/token', function (req, res) { var strMsg = ' request host: ' + thisHost; strMsg = strMsg + ' app host: ' + appHost; res.send('host restricted.' + strMsg); - res.end(); + return; } From 1c1da0d14bbf362755bc3597be2828cb2c963e15 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Mon, 11 May 2015 21:46:32 +0800 Subject: [PATCH 32/38] token restriction --- routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index 2a37e6b..dc6db93 100644 --- a/routes/api.js +++ b/routes/api.js @@ -62,7 +62,7 @@ router.get('/token', function (req, res) { if (!error && response.statusCode == 200) { // Website you wish to allow to connect - res.setHeader('Access-Control-Allow-Origin', thisHost); + res.setHeader('Access-Control-Allow-Origin', appHost); // Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET'); From 2be123521c134fa062a76582dea9173714e4c417 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 11:04:27 +0800 Subject: [PATCH 33/38] add cors preflight --- routes/api.js | 24 +++++++++++++++--------- server.js | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/routes/api.js b/routes/api.js index dc6db93..9ca70d4 100644 --- a/routes/api.js +++ b/routes/api.js @@ -21,9 +21,15 @@ var request = require('request'); var router = express.Router(); +var cors = require('cors'); + +var corsOptions = { + origin: 'http://secure-token.herokuapp.com' +}; + router.get('/tokenadsk', function (req, res) { - //steals access token from a360 + //steals access token from http://secure-token.herokuapp.com request('http://secure-token.herokuapp.com/api/token', function (error, response, body) { if (!error && response.statusCode == 200) { @@ -36,22 +42,22 @@ router.get('/tokenadsk', function (req, res) { /////////////////////////////////////////////////////////////////////////////// // Generates access token /////////////////////////////////////////////////////////////////////////////// -router.get('/token', function (req, res) { +router.get('/token', cors(corsOptions),function (req, res) { var params = { client_id: process.env.ConsumerKey , client_secret: process.env.ConsumerSecret, grant_type: 'client_credentials' } - var thisHost = req.protocol + '://' + req.get('host'); + // var thisHost = req.headers.refer;//req.protocol + '://' + req.get('host'); var appHost = 'http://secure-token.herokuapp.com'; - if (thisHost != appHost) { - var strMsg = ' request host: ' + thisHost; - strMsg = strMsg + ' app host: ' + appHost; - res.send('host restricted.' + strMsg); - return; - } + // if (thisHost != appHost) { + // var strMsg = ' request host: ' + thisHost; + // strMsg = strMsg + ' app host: ' + appHost; + // res.send('host restricted.' + strMsg); + // return; + // } request.post( diff --git a/server.js b/server.js index 8e6b864..4350ea8 100644 --- a/server.js +++ b/server.js @@ -19,12 +19,14 @@ var favicon = require('serve-favicon'); var api = require('./routes/api'); var express = require('express'); +var cors = require('cors'); var app = express(); app.use('/', express.static(__dirname + '/www')); app.use(favicon(__dirname + '/www/images/favicon.ico')); app.use('/api', api); +app.use(cors); app.set('port', process.env.PORT || 3000); From 53a1f5f4b2f62ed944c3bf9ffd9e33e626e5f168 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 11:13:13 +0800 Subject: [PATCH 34/38] add cors --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ca31ca7..383cc25 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "serve-favicon": "*", "stringstream": "0.0.4", "tough-cookie": "^0.13.0", - "tunnel-agent": "^0.4.0" + "tunnel-agent": "^0.4.0", + "cors" : "*" } } From 80347edde2d6f3263023352022c422ac90cb208d Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 12:02:41 +0800 Subject: [PATCH 35/38] add travis cI --- .travis.yml | 7 +++++++ routes/api.js | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cd4273f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "0.12" + - "0.11" + - "0.10" + - "0.8" + - "0.6" diff --git a/routes/api.js b/routes/api.js index 9ca70d4..5114bf3 100644 --- a/routes/api.js +++ b/routes/api.js @@ -50,7 +50,7 @@ router.get('/token', cors(corsOptions),function (req, res) { } // var thisHost = req.headers.refer;//req.protocol + '://' + req.get('host'); - var appHost = 'http://secure-token.herokuapp.com'; + //var appHost = 'http://secure-token.herokuapp.com'; // if (thisHost != appHost) { // var strMsg = ' request host: ' + thisHost; @@ -68,10 +68,10 @@ router.get('/token', cors(corsOptions),function (req, res) { if (!error && response.statusCode == 200) { // Website you wish to allow to connect - res.setHeader('Access-Control-Allow-Origin', appHost); + //res.setHeader('Access-Control-Allow-Origin', appHost); // Request methods you wish to allow - res.setHeader('Access-Control-Allow-Methods', 'GET'); + //res.setHeader('Access-Control-Allow-Methods', 'GET'); // // Request headers you wish to allow // res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); From 8d74721a0d71edae91c14ec8bf4cda55336707fb Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 12:06:55 +0800 Subject: [PATCH 36/38] update --- routes/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/api.js b/routes/api.js index 5114bf3..a8135f9 100644 --- a/routes/api.js +++ b/routes/api.js @@ -39,6 +39,7 @@ router.get('/tokenadsk', function (req, res) { }); + /////////////////////////////////////////////////////////////////////////////// // Generates access token /////////////////////////////////////////////////////////////////////////////// From 89d7a5ad7b8bdd653589d48fbfbbeb11431ad736 Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 12:09:51 +0800 Subject: [PATCH 37/38] update travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd4273f..cf5deb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,4 @@ node_js: - "0.12" - "0.11" - "0.10" - - "0.8" - - "0.6" + From ac1ce0df00f8edd0f62cc44f194325dbcbaf678b Mon Sep 17 00:00:00 2001 From: Daniel Du Date: Tue, 12 May 2015 12:19:34 +0800 Subject: [PATCH 38/38] update readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 85a9257..253cf40 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Autodesk View and Data API Node.js Basic Sample +[![build status](https://api.travis-ci.org/duchangyu/workflow-node.js-view.and.data.api.png)](https://api.travis-ci.org/duchangyu/workflow-node.js-view.and.data.api) + + ## Description A sample demonstrating how to view a model in a web application with the Autodesk View & Data API. This web application has a basic Node.js