How to Use an Authorization Token in Angular PDF Viewer
14 Aug 20261 minute to read
The PDF Viewer supports adding an authorization token to every AJAX request by configuring the ajaxRequestSettings.ajaxHeaders property. Set the header once and the library includes it in all requests initiated by the viewer.
The following steps show how to include the authorization token in the PDF Viewer control.
Step 1: Follow the steps provided in the link to create simple PDF Viewer sample in Angular.
Step 2: Add the following code snippet to include the authorization token.
<ejs-pdfviewer id="pdfViewer"
[serviceUrl]='service'
[documentPath]='document'
[ajaxRequestSettings]="ajaxSetting"
style="height:640px;display:block">
</ejs-pdfviewer>public ajaxSetting = {
ajaxHeaders: [
{
headerName: "Authorization",
headerValue: "Bearer 64565dfgfdsjweiuvbiuyhiueygf"
}
],
withCredentials: false
};Find the Sample how to include authorization token