1

My current stack is React-Native that uses a WebView with forge(v7.15) in it. My API is a symfony API and it has a authenticated route that receives the filename and returns me a BinaryFileResponse based on the file.

Basically what I'm wanting to do is:

actual:
viewer = new Autodesk.Viewing.Private.GuiViewer3D(document.getElementById('forgeViewer'));
viewer.loadModel('API_URL/route/filename');

expected:
viewer = new Autodesk.Viewing.Private.GuiViewer3D(document.getElementById('forgeViewer'));
viewer.loadModel('API_URL/route/filename', jwtToken); //or something like that.

Atm, everything works fine. But I want to change the route to be authenticated and I don't know how I can do that, and if I can do that. I have my JWT token saved on client-side and I want to pass it on header/or anything that helps me to achieve that.

Is there a way to use the loadModel and send a JWT token to the URL that viewer will try to load?

  • 1
    I'm trying to understand what are you trying to do, what is this JWT token for? The viewer API has defined already in the method what parameters will take, you can see those in the documentation, I don't think it will take external values like a token to authenticate to a 3rd party service, I would suggest doing this in an external call. For reference here is the loadmodel method documentation - https://forge.autodesk.com/en/docs/viewer/v7/reference/Viewing/Viewer3D/#loadmodel-url-options-onsuccesscallback-onerrorcallback – Jaime Rosales May 24 '21 at 21:44
  • hey @JaimeRosales, the loadModel receives a file/model URL that will be loaded, correct? The URL that I pass to this method will make a request to my server(backend api) that expects to receive the model/file to be loaded. Today we already work like this, making the request and returning the PDF for example, and everything works fine. I want this route, that the request was made, to be authenticated. The JWT token is to access the authenticated route. I tried getting the model before(using the jwt) the loadModel and then passing the object to it, but it doesn't support this. – Vinicius Almeida May 25 '21 at 12:21
  • I'm facing the exact same issue as this - did you find a solution? Thanks – LaZe Jun 11 '21 at 17:12
  • @LaZe, I changed the back-end to accept the token as a query parameter, so the URL that I pass to the loadModel is API_URL/?bearer=token Hope it helps you :) – Vinicius Almeida Jun 12 '21 at 18:09
  • @ViniciusAlmeida I think I'll go with your suggestion, because I don't really see any alternatives. Thanks! – LaZe Jun 13 '21 at 19:29

0 Answers0