/propertyServer

Forge Model PropertyServer to workaround the Model Derivative API limitations

Primary LanguageJavaScriptMIT LicenseMIT

propertyServer sample

Node.js npm Platforms License

Forge API: oAuth2 Model-Derivative

Note: For using this sample, you need a valid oAuth credential for accessing resources on Autodesk Forge. Visit this page for instructions to get on-board.

Description

The propertyServer server exercises a workaround to the Forge Model Derivative API limitations to request properties. It also demonstrates how to parse the bubble json.gz property files.

In order to make use of this sample, you need to register your consumer and secret keys:

This provides the credentials to supply to the http requests to the Autodesk server endpoints.

Dependencies

This sample is dependent on the server part on Node.js and couple of Node.js extensions which would update/install automatically via 'npm':

Setup/Usage Instructions

Deploy on Heroku

Deploy

Setup

  1. Download and install Node.js (that will install npm as well)

  2. Download this repo anywhere you want (the server will need to write files, so make sure you install in a location where you have write permission, at least the 'tmp', 'data' and '/www/extracted' folders)

  3. Execute 'npm install', this command will download and install the required node modules automatically for you.

    npm install
    
  4. Install your credential keys:
    Use system environment variables (This is actually the option you need to use for the tests suite which runs on Travis-CI). Replace keys placeholder xxx with your own keys.

       * Windows<br />
         ```
         set FORGE_CLIENT_ID=xxx
    
         set FORGE_CLIENT_SECRET=xxx
     
     set FORGE_CALLBACK=xxx
    
         [set PORT=<port>]
    
     	node start.js
         ```
       * OSX/Linux<br />
         ```
         [sudo] [PORT=<port>] FORGE_CLIENT_ID=xxx FORGE_CLIENT_SECRET=xxx FORGE_CALLBACK=xxx node start.js
         ```
    

    Note: the port argument can be omitted and default to port 80. If port 80 is already in use by another application (like Skype, or IIS, or Apache, ...), you can use any other free port such as 8000, 3000, etc... But in the next section you would need to specify the port to use, i.e. http://localhost[:port]/

Use of the sample

  1. Get resources from your file
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load

Note the server, use a 2 legged definition by default, but you can override the Authorization by adding an header to the request in order to use your own.

curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load -H "Authorization: Bearer ey9f...ks7A"
  1. Verify resources are ready
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load/progress
  1. Get IDs and ExternalIDs
# Get the highest ID
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/range

# Get all externalIDs
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/*

# Get externalIDs for 1 object with Id == 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1789

# Get externalIDs for several objects with Id == 1066, 1515, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1066,1515,1789

# Get externalIDs for group of objects with Id between 1515 and 1531
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1515-1531

# Get externalIDs for group of objects with Id between 1515 and 1531 and few other objects with Id == 1066, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1066,1515-1531,1789

  1. Get properties
# Get all properties
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/*

# Get properties for 1 object with Id == 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1789

# Get properties for several objects with Id == 1066, 1515, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1066,1515,1789

# Get properties for group of objects with Id between 1515 and 1531
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1515-1531

# Get properties for group of objects with Id between 1515 and 1531 and few other objects with Id == 1066, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1066,1515-1531,1789

Note you can add the -H "Accept-Encoding: gzip" or -H "Accept-Encoding: deflate" or -H "Accept-Encoding: gzip, deflate" to compress the JSON reply.

  1. Free the resources if you do not need it any more
curl -X DELETE http://localhost:3000/data/dXJuO...Lm53ZA

BIM360docs and 3legged support

The only time you need a different token than the one generated and used by the server is when you want to access a database coming from a file stored on BIM360docs / Fusion360. In this case, you need a 3legged token which requires you to log with a user credentials. You can get teh token from your application or get help from this server as long you provisionned your keys on the service.

This is where you need to define the FORGE_CALLBACK environment variable, and in your browser go to http://localhost:3000/3legged. After the login process, you should see an access_token on the page you can use to load the database resource on the propertyServer.


License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Cyrille Fauvel
Forge Partner Development
http://developer.autodesk.com/
http://around-the-corner.typepad.com