Include the Authorization token in Blazor PDF Viewer Component
17 Dec 20221 minute to read
The Syncfusion’s Blazor PDF Viewer component allows to include the authorization token in the PDF viewer AJAX request using the properties of the ajaxRequest header available in AjaxRequestSettings
, and it will be included in every AJAX request send from PDF Viewer.
The following code example shows how include the authorization token.
@using Syncfusion.Blazor.PdfViewer
<SfPdfViewer @ref="PdfViewer" ServiceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer" DocumentPath="@DocumentPath" AjaxRequestSettings="@AjaxRequestSettings" Height="500px" Width="1060px">
</SfPdfViewer>
@code{
SfPdfViewer PdfViewer;
private string DocumentPath { get; set; } = "PDF_Succinctly.pdf";
public PdfViewerAjaxRequestSettings AjaxRequestSettings = new PdfViewerAjaxRequestSettings{
AjaxHeaders = new List<AjaxHeader>() {
new AjaxHeader {
HeaderName = "Authorization",
HeaderValue = "Bearer 64565dfgfdsjweiuvbiuyhiueygf"
},
},
WithCredentials = false
};
}
NOTE
AjaxRequestSettings
is applicable for Web assembly blazor alone.
NOTE
Find the sample, How to include the authorization token
NOTE
You can refer to our Blazor PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our Blazor PDF Viewer example to understand how to explains core features of PDF Viewer.