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

202 Views Asked by At

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"?

1

There are 1 best solutions below

0
On

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}"
} };