Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/autodesk-platform-services/aps-tokenflex-export

A boilerplate Forge app to report on TokenFlex usage data
https://github.com/autodesk-platform-services/aps-tokenflex-export

autodesk-tokenflex koa2 nodejs sample vuejs

Last synced: about 1 month ago
JSON representation

A boilerplate Forge app to report on TokenFlex usage data

Awesome Lists containing this project

README

        

# consumption-reporting-vue-koa-app

[![TokenFlex](https://img.shields.io/badge/TokenFlex-v1-green.svg)](https://aps.autodesk.com/en/docs/tokenflex/v1/overview/)
[![koa2](https://img.shields.io/badge/koa-2-green.svg)](https://github.com/koajs/koa)
[![vuetify](https://img.shields.io/badge/Vuetify-1.3-blue.svg)](https://github.com/vuetifyjs/vuetify)
[![oauth](https://img.shields.io/badge/passport--oauth-1-brightgreen.svg)](https://github.com/jaredhanson/passport-oauth)

[![travisCI](https://travis-ci.org/dukedhx/consumption-reporting-vue-koa-app.svg?branch=master)](https://travis-ci.org/dukedhx/consumption-reporting-vue-koa-app)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![codebeat badge](https://codebeat.co/badges/d26ae8ba-e166-4f2a-9357-52d7c126391a)](https://codebeat.co/projects/github-com-dukedhx-consumption-reporting-vue-koa-app-master)
[![Maintainability](https://api.codeclimate.com/v1/badges/79b42eaa59c06ec13703/maintainability)](https://codeclimate.com/github/dukedhx/consumption-reporting-vue-koa-app/maintainability)
[![MIT](https://camo.githubusercontent.com/b323cc1dc1fbf413e36d79b86abc71b68b648e4b/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f767565746966792e737667)](https://opensource.org/licenses/MIT)

[![zenhub](https://camo.githubusercontent.com/7e10f7ff8cd1064be463e8846910c6a2aa2d2567/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616e616765645f776974682d5a656e4875622d3565363062612e737667)](https://app.zenhub.com/workspace/o/dukedhx/consumption-reporting-vue-koa-app/)
[![Stackoverflow](https://img.shields.io/badge/ask-stackoverflow-yellow.svg)](https://stackoverflow.com/questions/ask?tags=%5bautodesk-aps)

## Description

Demonstrates how to build custom reports using APS TokenFlex API.

Uses [3-legged oAuth2](https://aps.autodesk.com/en/docs/oauth/v2/tutorials/get-3-legged-token/) to authenticate with APS. Uses [chart.js](http://www.chartjs.org/) and [Google Maps](https://developers.google.com/maps/documentation/javascript/tutorial) API to create usage dashboard.

### Thumbnail

![Thumbnail](/thumbnail.png)

### [Live Demo](https://tokenflex-consumption-report.herokuapp.com)

### Pre-requisites

- APS Account: Learn how to create a APS Account, activate subscription and create an app at [this tutorial](http://learnaps.autodesk.io/#/account/)
- 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](https://developers.google.com/maps/documentation/javascript/get-api-key)
- 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.

### Setup

- Create a APS App with access to the `Misc API`.

- Clone this project or download it. It's recommended to install [GitHub desktop](https://desktop.github.com/). 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

```bash
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
```

### Running Locally

- To run the front end with the Vue LiveServer (see it live at http://localhost:8080/):

```bash
npm run serve
```

- To run the app in dev mode (see it live at http://localhost:5000/):

```bash
npm run dev
```

### Debug Options

To apply new Client ID/Secret or Callback URL, run below to recreate the config file

```bash
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`):

```bash
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/):

```bash
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](http://javascriptlint.com/) the source code:

```bash
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

### Deployment

To deploy this application to [Heroku](https://heroku.com/), make sure the following [config vars](https://devcenter.heroku.com/articles/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:

```
.herokuapp.com/api/aps/callback/oauth
```

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/mazerab/consumption-reporting-vue-koa-app)

Watch [this video](https://www.youtube.com/watch?v=Oqa9O20Gj0c) on how to deploy samples to Heroku.

### Further Reading

Documentation:

- [Authentication API](https://aps.autodesk.com/en/docs/oauth/v2/developers_guide/overview/)

Tutorials:

Blogs:

- [APS Blog](https://aps.autodesk.com)

Other samples:

- [Python script](https://github.com/mazerab/aps-consumption-reporting-sample) to download usage data to CSV file

For any questions regarding this sample or the technologies involved, ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=%5bautodesk-aps,aps-tokenflex) or email to Autodesk APS Developer Advocates.

### License

This sample is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT). Please see the [LICENSE](LICENSE) file for full details.

### Authors

- Bastien Mazeran [@BastienMazeran](https://twitter.com/BastienMazeran)
- Bryan Huang [@LinkedIn](https://linkedin.com/in/bryan-huang-1447b862)

See more at [APS blog](https://aps.autodesk.com/blog).