This sample provides example of using Tandem Viewer in React application. It covers following concepts:
- Using 3-legged authentication
- How to wrap Tandem Viewer by React component
- How to get list of facilities for user
- How to display default view of facility
- Node.js
- Vite
- VS Code (another IDE can be used as well)
This is assuming you're using VS Code as your development editor. It's possible to use another environment but steps below may differ.
Follow these steps to run application locally:
- Run
git clone
to clone repository. The repo has two sub folders:server
client
- Start VS Code and open
server
folder. - Run
npm install
. - Update
.env
file with your details. - Run server under debugger (Run - Start Debugging or F5).
- Open new VS Code window (File - New Window).
- Open
client
folder. - Run
npm install
. - Open terminal and run
npm run dev
. - Open your browser and navigate to http://localhost:3000
The server is simple Node.js server which exposes following end points:
/api/auth/url
- provides authorization URL./api/auth/callback
- it's called by APS Authentication service when user is authenticated./api/auth/token
- provides valid to to client. Then token is used by viewer to display facility./api/userprofile
- provides information about user for active session.
- When the application is loaded it check if there is user information available for current session.
- User can click Login button to start authentication flow.
- Application redirects to authorization URL provided by back end.
- User can now authenticate using Autodesk ID.
- After succesfull authentication user is redirect back to application.
- The application check user profile again. Now it's valid so
Viewer
component is created. This triggeronAppInitialized
callback. From within the callback the drop down is populated by available facilities. - When user selects facility it's passed to
Viewer
component. The facility is loaded and default view is set as active.