'How to include Auth in Syncfusion PDF Viewer ServiceUrl Api Call in a Blazor WASM app

I am trying to use Syncfusion PDF Viewer in a Blazor WASM app with authentication, and am getting the following error:

Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenNotAvailableException: ''

I know this is because there is Auth set up and that is not getting attached to the API call, does anyone know how to configure Syncfusion to add auth to its API call in the PDF viewer "ServiceUrl"?



Solution 1:[1]

Add a node inside the PDF Viewer, like so:

<PdfViewerAjaxRequestSettings AjaxHeaders="Headers" />

Then, in the @code section,

public List<AjaxHeader> Headers => new() { new AjaxHeader
{
    HeaderName = "Authorization", 
    HeaderValue = $"Bearer {_token}"
} };

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hoecuspocus