tokenflex-reporting

by mazerab

GitHub Readme.md

consumption-reporting-vue-koa-app

TokenFlex koa2 vuetify oauth
travisCI JavaScript Style Guide codebeat badge Maintainability MIT
zenhub Stackoverflow

Description

Demonstrates how to build custom reports using Forge TokenFlex API.

Uses 3-legged oAuth2 to authenticate with Forge. Uses chart.js and Google Maps API to create usage dashboard.

Thumbnail

Thumbnail

Live Demo

Pre-requisites

  • Forge Account: Learn how to create a Forge 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 Forge subscription to the Forge 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.

Setup

  • Create a Forge 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-Forge/tokenflex-nodejs-report.webapp
  • Initialize and install the dependencies
export FORGE_CLIENT_ID=[YOUR_CLIENT_ID]
export FORGE_CLIENT_SECRET=[YOUR_CLIENT_SECRET]
export FORGE_CALLBACK_URL=[YOUR_CALLBACK_URL]
export GoogleAPIKey=[YOUR_GOOGLEAPI_KEY]
npm install

Running Locally

npm run serve
npm run dev

Debug Options

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:

  • FORGE_AUTH_URL
  • FORGE_TOKEN_URL
  • TOKENFLEX_PATH
  • TOKENFLEX_API_HOST
  • LOGOUTACCOUNT_URL
  • VUE_HOST

Deployment

To deploy this application to Heroku, make sure the following config vars are set up correctly:

  • FORGE_CLIENT_ID
  • FORGE_CLIENT_SECRET
  • FORGE_CALLBACK_URL
  • GoogleAPIKey

And FORGE_CALLBACK_URL must follow the pattern below and match the one set for your Forge APP:

<nameofyourapp>.herokuapp.com/api/forge/oauth

Deploy

Watch this video on how to deploy samples to Heroku.

Further Reading

Documentation:

Tutorials:

Blogs:

Other samples:

For any questions regarding this sample or the technologies involved, ask a question on Stack Overflow or email to Autodesk Forge Developer Advocates.

License

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

Authors

See more at Forge blog.