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 cloneto clone repository. The repo has two sub folders:serverclient
- Start VS Code and open
serverfolder. - Run
npm install. - Update
.envfile with your details. - Run server under debugger (Run - Start Debugging or F5).
- Open new VS Code window (File - New Window).
- Open
clientfolder. - 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
Viewercomponent is created. This triggeronAppInitializedcallback. From within the callback the drop down is populated by available facilities. - When user selects facility it's passed to
Viewercomponent. The facility is loaded and default view is set as active.