Demonstrates how to build custom reports using APS TokenFlex API.
Uses 3-legged oAuth2 to authenticate with APS. Uses chart.js and Google Maps API to create usage dashboard.
- APS Account: Learn how to create a APS Account, activate subscription and create an app at this tutorial
- Node.js >= 8.0
- Internet connectivity to the Google Map API
- Tested to be working on: Chrome, Safari, Firefox and IE Edge
- A Google API Key for Google Maps, you can get one here
- When logging into the web dashboard, you should login with the Autodesk ID of a contract manager or software coordinator to gain access to the contracts' usage data. If you login with a user that does not have such roles, the API will return no data.
- In order to access TokenFlex API, your contract manager needs to login in the accounts portal and assign the APS subscription to the APS account user. Before he can assign the subscription he will need to unassign the subscription from his user account. Contact your account manager for assistance.
-
Create a APS App with access to the
Misc API
. -
Clone this project or download it. It's recommended to install GitHub desktop. To clone via command line, use the following (Terminal on MacOS/Linux, Git Shell on Windows):
git clone https://github.com/autodesk-platform-services/tokenflex-nodejs-report.webapp
- Initialize and install the dependencies
export APS_CLIENT_ID=[YOUR_CLIENT_ID]
export APS_CLIENT_SECRET=[YOUR_CLIENT_SECRET]
export APS_CALLBACK_URL=[YOUR_CALLBACK_URL]
export GoogleAPIKey=[YOUR_GOOGLEAPI_KEY]
npm install
- To run the front end with the Vue LiveServer (see it live at http://localhost:8080/):
npm run serve
- To run the app in dev mode (see it live at http://localhost:5000/):
npm run dev
To apply new Client ID/Secret or Callback URL, run below to recreate the config file
npm run init '[YOUR_CLIENT_ID]' '[YOUR_CLIENT_SECRET]' '[YOUR_CALLBACK_URL]' '[YOUR_GOOGLEAPI_KEY]'
To build the front end (Compiler will emit build outputs to ./www
):
npm run build
To run both the front and back ends in single APP mode, you will need to have built the front end beforehand (see it live at http://localhost:8080/):
NODE_ENV=production npm run init '[YOUR_CLIENT_ID]' '[YOUR_CLIENT_SECRET]' '[YOUR_CALLBACK_URL]' '[YOUR_GOOGLEAPI_KEY]'# Settimg up prod config for first time use
npm run prod
To lint the source code:
npm run lint # eslint with Javascript Standard Style for frontend code
npm run standard # eslint with Javascript Standard Style for backend code
Optional Environment Variables, leave them empty for default values:
- APS_AUTH_URL
- APS_TOKEN_URL
- TOKENFLEX_PATH
- TOKENFLEX_API_HOST
- LOGOUTACCOUNT_URL
- VUE_HOST
To deploy this application to Heroku, make sure the following config vars are set up correctly:
- APS_CLIENT_ID
- APS_CLIENT_SECRET
- APS_CALLBACK_URL
- GoogleAPIKey
And APS_CALLBACK_URL must follow the pattern below and match the one set for your APS APP:
<nameofyourapp>.herokuapp.com/api/aps/callback/oauth
Watch this video on how to deploy samples to Heroku.
Documentation:
Tutorials:
Blogs:
Other samples:
- Python script to download usage data to CSV file
For any questions regarding this sample or the technologies involved, ask a question on Stack Overflow or email to Autodesk APS Developer Advocates.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
- Bastien Mazeran @BastienMazeran
- Bryan Huang @LinkedIn
See more at APS blog.