authorizationautodesk-forgeautodesk-viewerrefresh-token

Viewer SDK - Access Token Management with Automatic Routing


I am looking for​ guidance on how to configure authorization token management with automatic routing enabled in the Viewer SDK.

Our application sets up token refreshing using the getAccessToken callback in the Autodesk.Viewing.Initializer options, as outlined in the Getting Started Guide. Automatic routing is setup by setting the "DS_ENDPOINTS" flag. I can confirm that the access token callback is invoked on current token expiry and that the refreshed token is passed to onTokenReady. However, subsequent calls to Autodesk.Viewing.Document.load still seem to use the initial token even after it has expired instead of the new token sent in the callback. This results in 403 errors when the viewer attempts to fetch the document manifest and prevents documents from rendering successfully. Without the "DS_ENDPOINTS" feature enabled, token refreshing appears to work correctly. We are currently using version 7.110.1 of the viewer.

So far, I have attempted the following workarounds to properly handle token refreshing but none have been successful:

  1. Update to the recent viewer version: 7.112.1
  2. Manually setting the legacy endpoint headers at: Autodesk.Viewing.endpoint.HTTP_REQUEST_HEADERS.Authorization
  3. Passing the current authorization header in the options parameter of Autodesk.Viewing.Document.load

Steps to reproduce:

  1. Setup and start the aps-hubs-browser-nodejs
  2. Load a few different models
  3. Wait until initial token expiry (usually ~1 hr in my testing)
  4. Try loading the same models

Expected result: Models are rendered correctly

Actual result: The viewer reports an error and the models do not render. A 403 error is reported in the browser console.


Solution

  • To close the loop, token refreshing now works correctly with automatic routing with the latest update from Autodesk in Viewer SDK version 7.114.0.