Skip to content

Authorization and file translation demo: Demonstrates Autodesk Forge API authorization and translation process using cURL

License

Notifications You must be signed in to change notification settings

cyrillef/forge.commandline-curl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cUrl Platforms License

Forge API: oAuth2 Data-Management OSS Model-Derivative Viewer

forge.commandline-curl

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

Demonstrates the Autodesk Forge API authorisation and translation process using cURL in command line scripts.

Description

This sample exercises the cURL command demonstrating the Forge OAuth authorisation and Model Derivatives API mentioned in the Quick Start guide.

In order to make use of this sample, you need to register your consumer key, of course:

This provides the credentials to supply while calling the Forge WEB service API endpoints.

Dependencies

Standard OS functionality, Bash, cURL and JQ.

This sample targets Mac OSX and Unix only, it should run on different distribution of Linux but was tested on Ubuntu and Fedora only at this time.

Windows user, you need to install a Unix shell like cygwin or Git for Windows, but the sample requires bash 3.2 minimum to run. See the Windows special setup instructions for more details.

Setup/Usage Instructions

Windows user, see Windows special setup instructions below first.

  1. Make sure cURL is installed in your system; if not, please refer to the cURL releases and downloads.
  2. Check that cURL is running in a Terminal window:
    curl -V
    
  3. Request your consumer key/secret key from https://developer.autodesk.com.
  4. Set 2 environment variables FORGE_CLIENT_ID / FORGE_CLIENT_SECRET to hold your consumer key/secret keys.
  5. Install JQ
    brew install jq
    

The ./forge scripts provide quick help information for the commands and arguments.

A typical workflow is:

# Do authentication
./forge 2legged

# Create a bucket. Bucket name must be lower case and valid characters
./forge bucketCreate my_bucket_name

# Upload a model
./forge upload samples/Au.obj

# Translate the model
./forge translate Au.obj

# Wait until the translation completes.
# Translation is complete when it reaches 'success - 100%'
./forge translateProgress Au.obj

# Retrieve preview image (png saved into ./temp/)
./forge thumbnail Au.obj

# View the model in your localhost WEB site (html saved into ./temp/)
./forge html Au.obj

Note your access token and bucket name are saved in the data folder to be used as default by the scripts, but you can edit them as you wish.

Bucket information (JSON replies) returned by the system is stored in the data folder as well.

Windows special setup instructions

This sample was tested on Windows with the git for windows package. It provides a nice terminal windows running Bash v4.3 and cUrl v7.51 already installed.

  1. Go to http://git-for-windows.github.io/ and install the package. Select the default options.
  2. Go to https://stedolan.github.io/jq/download/, install JQ, and rename it to jq.
  3. Start the 'Git Bash' Terminal window from the Desktop icon, or a shortcut running this command "C:\Program Files\Git\git-bash.exe" --cd-to-home
  4. Put the sample directory into the PATH.
  5. You can now continue with the normal setup instructions.

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

About

Authorization and file translation demo: Demonstrates Autodesk Forge API authorization and translation process using cURL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages