# License Error/ License API not getting called

**URL:** <https://pdfjs.community/t/license-error-license-api-not-getting-called/1726>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [May 31, 2022, 2:07pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726 "2022-05-31T14:07:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjit.intelegent88](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranjit.intelegent88](https://pdfjs.community/u/ranjit.intelegent88)\
**Post date:** [May 31, 2022, 2:07pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/1 "2022-05-31T14:07:23Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer

**PDF.js Express Version**

Core Version- **8.4.0** ,  
UI Version - **8.4.1**

**Detailed description of issue**  
This issue is happening randomly & the license key API is not getting called most of the times, some time it calls the API some times not & the result of that is the document is not loading, see the attached image below. This is so annoying. see the Screenshot below

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ac494d12cf45eb60d95ae2bde3dbdea915b8e20d.png)

**Expected behaviour**  
The Document should display & should not show License key error in console as we are using valid key,

**Does your issue happen with every document, or just one?**  
All Documents

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
See below

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/95766b07cc673fe0194eddec127c6eabab4f00de.png)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [May 31, 2022, 2:07pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/3 "2022-05-31T14:07:29Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:
- [Adding your license key - PDF.js Express Plus License Keys](https://pdfjs.express/documentation/get-started/add-license-key#pdf.js-express-plus-license-keys-<span-class='plus'></span>)
- [Migrating from PDF.js Express to PDFTron - 3. Change initiation](https://pdfjs.express/documentation/learn-more/pdfjs-express-to-pdftron.8#3.-change-initiation)
- [Set XFDF using the Express REST API - Body params](https://pdfjs.express/documentation/utils/set#body-params)

APIs:
- [Core.Annotations.WidgetAnnotation - setModified( [shouldKeepAppearance])](https://pdfjs.express/api/Core.Annotations.WidgetAnnotation.html#setModified__anchor)
- [Core - preloadPDFWorker(pdfBackendType, workerHandlers)](https://pdfjs.express/api/Core.html#.preloadPDFWorker__anchor)
- [UI.MentionsManager - one(type, fn)](https://pdfjs.express/api/UI.MentionsManager.html#one__anchor)

Forums:
- [Is it possible to hide authentication key GET api from network?](https://pdfjs.community/t/is-it-possible-to-hide-authentication-key-get-api-from-network/562/1)
- [Net::ERR\_CERT\_DATE\_INVALID Error in using License Key](https://pdfjs.community/t/net-err-cert-date-invalid-error-in-using-license-key/235/1)
- [Watermark api fail to compile with demo haven’t purchased a licence key yet](https://pdfjs.community/t/watermark-api-fail-to-compile-with-demo-havent-purchased-a-licence-key-yet/471/1)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 2, 2022, 2:08pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/4 "2022-06-02T14:08:55Z")

</div>

Hi there,

This error happens when a license key is not provided at all to the PDF.js Express constructor. Your screenshot shows you passing a key so my suspicion is that either you are seeing a cached version of your page where you don’t pass a key, or you are calling the constructor elsewhere in your code.

Please try the following

- Clearing your cache
- Reinstalling PDF.js Express Viewer and making sure to properly replace all the static assets (delete the old ones and then reinstall)
- Make sure you aren’t accidentally calling the constructor elsewhere
- Make sure all the assets are being loaded correctly (check the network tab for any 404s)

If none of these fixes it, providing a link to this environment so I can test it myself would be helpful.

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![ranjit.intelegent88](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranjit.intelegent88](https://pdfjs.community/u/ranjit.intelegent88)\
**Post date:** [June 6, 2022, 5:48pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/5 "2022-06-06T17:48:16Z")

</div>

Hello Logan, Thanks for the insight. We are calling the page every time Not cached version & the constructor is being called every time otherwise how . So 'if I refresh the page 5 times 3 times the license error is coming & 2 times its loading correctly. Please help me.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 7, 2022, 1:59pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/6 "2022-06-07T13:59:49Z")

</div>

Hi there,

Are you able to provide me a link to the environment where I can see the error happening?

Logan

---

<div class="post-metadata">

**Author:** ![ranjit.intelegent88](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranjit.intelegent88](https://pdfjs.community/u/ranjit.intelegent88)\
**Post date:** [June 7, 2022, 6:41pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/7 "2022-06-07T18:41:08Z")

</div>

Hi Logan, due to HIPAA compliance, I won’t be able to provide you the Link, I can only send you walkthrough video link. Will that work?  
Please suggest me some solution. This thing is Random

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 7, 2022, 6:59pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/8 "2022-06-07T18:59:59Z")

</div>

Hi there,

A video walkthrough won’t be helpful as I need to be able to access the network tab and see whats going on.

I am fairly confident that this is an issue in your code somewhere and not an issue with our library.

Some things you can check for me:

- When the license does not get triggered and you see the error, are you able to inspect the source code in the developer console and confirm that the license key is set correctly?

- When the license does not get triggered and you see the error, do you see any network requests in the network tab going to [auth.pdfjs.express](http://auth.pdfjs.express)? If so, can you export those requests and send them to me?

- Can you confirm that ‘webviewer.min.js’ is not getting loaded twice in the network tab?

Thanks,  
Logan

---

<div class="post-metadata">

**Author:** ![ranjit.intelegent88](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranjit.intelegent88](https://pdfjs.community/u/ranjit.intelegent88)\
**Post date:** [June 7, 2022, 7:54pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/9 "2022-06-07T19:54:33Z")

</div>

This is the network tab when the license key api not calling

![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/fda84601abf80561866595c6fe9c8420cc4ce10a.png)

Below screenshot is when the PDF viewer works, you can compare with above

![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/a33643798ca5988a198924969e9e1edc8ca80d6f.png)

Below is auth api call

[https://auth.pdfjs.express/?key=oXh2N5oqgKQRneKQ7a6z&r=1](https://auth.pdfjs.express/?key=oXh2N5oqgKQRneKQ7a6z&r=1)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 7, 2022, 7:59pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/10 "2022-06-07T19:59:52Z")

</div>

Hi,

The API is only called when a document is loaded for the first time. Do you only see the error when loading a certain kind of document? In the code you provided in the original message you have two code paths for `UI.loadDocument`, do you see the error for both of those code paths?

Logan

---

<div class="post-metadata">

**Author:** ![ranjit.intelegent88](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ranjit.intelegent88](https://pdfjs.community/u/ranjit.intelegent88)\
**Post date:** [June 7, 2022, 8:40pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/11 "2022-06-07T20:40:28Z")

</div>

Hi, If I keep refreshing the same page again & again. Out of 10 refresh 6 times its failing & 4 times its successful. Lets say I open the page for the first time the viewer didn’t load but if I refresh the page it loads perfect. If I again refresh it may load or may not by throwing License error. its Random behavior. Hope you understand.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 7, 2022, 8:48pm UTC](https://pdfjs.community/t/license-error-license-api-not-getting-called/1726/12 "2022-06-07T20:48:24Z")

</div>

Hi there,

I unfortunately do not have enough information to help at the moment. I will either need access to your environment or consistent steps to reproduce. Without either of those I cannot help any further.

Let me know if you are able to uncover anything else.

Thanks,  
Logan
