How To: Request an Access Token for Autodesk APIs with Node.js

In this post I’ll demonstrate how to set up a simple Node.js server that will return an access token for Autodesk’s Web Service APIs. Every time you run the app, you’ll get a response in your console that contains the token.

Authentication API

Authentication API(link goes to official documentation) takes a POST request that contains your client id and secret in the request body. It sends you an access token that would expire in 1799 seconds – that is 30 minutes, to perform operations with Autodesk’s Web Service APIs.

The request:

POST /authentication/v1/authenticate HTTP/1.1
Host: developer.api.autodesk.com
Content-Type: application/x-www-form-urlencoded
client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials

The response body should look like this:

{
  "token_type": "Bearer",
  "expires_in": 1799,
  "access_token": "Ttj3qdRiNRGQsu975PPXF578hzmP"
}

Now that we understood what the API does, let’s get started! If you’d like to skip the tutorial, all the code is in a GitHub repo.

Continue reading How To: Request an Access Token for Autodesk APIs with Node.js