our use case for the HTML5 Viewer is the following:
- We have an API written in ASP NET MVC Core 3.1
- For authentication we’re using JWT, meaning every request that has to be authenticated on the API side has to have an ‘Authorization: Bearer …’ request header
- On the frontend we have a single page application written using Angular (v.9)
- We want to show a preview of the report
Since the HTML Viewer is only available for ASP.NET Core as a HTML helper for razor pages, we’ve added a server side rendered page that would host our viewer.
In order to authorize the Html5Viewer’s AJAX requests, there is code there that intercepts all XMLHttpRequests and adds an authentication header with the token from local storage.
This approach works, but not entirely - some of the requests are intercepted and some are not (I can’t figure out why is that):
Eg: Here the request with the preview is intercepted, the JWT gets added, and the request succeeds.
The following request with the thumbnail is not intercepted, the JWT is not added, and the request fails with 401 (which is correct - requests without bearer tokens should not be authorized).
First of all, this whole solution feels hacky, since I’m not configuring L&L, but rather adding custom code to add authentication.
Seconds of all, after spending some time with the docs, I haven’t found any reference to how to use the Html5Viewer with JWT tokens.
The question is:
Can you provide us with an example of how to configure the Html5Viewer to use JWT tokens (or point us to the documentation section that describes that, since I haven’t found any)