Search results

Include the Authorization token in React PDF Viewer component

02 Feb 2023 / 1 minute to read

The PDF Viewer library allows you 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.

Here is an example of how you can use the AjaxRequestSettings property to include the authorization token to the PDF viewer control:

Copied to clipboard
<PdfViewerComponent
  id="container"
  documentPath="PDF_Succinctly.pdf"
  serviceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer"
  ajaxRequestSettings={this.ajaxRequestSettings}
  style={{ height: '640px' }}>
</PdfViewerComponent>

// Include the Authorization token
ajaxRequestSettings = {
ajaxHeaders: [
  {
    headerName: 'Authorization',

    headerValue: 'Bearer 64565dfgfdsjweiuvbiuyhiueygf'
  }
],
withCredentials: false
};

Find the sample how to include authorization token