I am using pywebpush 1.4.0 library to push Web Notifications from Django backend. The keys that I'm using were obtained from https://web-push-codelab.glitch.me/. Subscription seems to working fine. Moreover, I tested this on Firefox and it is working fine there.
I receive the following error server side while pushing on Chrome:
Push failed: <Response [400]>: <HTML>
<HEAD>
<TITLE>UnauthorizedRegistration</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>UnauthorizedRegistration</H1>
<H2>Error 400</H2>
</BODY>
</HTML>
The strange part is that my backend controls 3 domains and push is working fine even for Chrome on one domain and not working on others. I ruled out the following possible issues:
- Improper Private and Public Key pairs as it is working fine on Firefox
- Outdated pywebpush library as on one domain on Chrome it is working fine
- Few answers (Chrome Web Notification Push Unauthorized Registration exception) pointed out to update the py-vapid version installed by pywebpush but it's version is already py-vapid==1.3.0
The only possibility I see is if Chrome doesn't allow push notifications on different domains from the same backend. Is anyone aware of such a limitation or could help me with any other pointers here?
Note: I'm using different keys for all the three domains.
Here is the code I'm using to push:
from pywebpush import webpush
webpush(subscription_info,
data,
vapid_private_key=vapid_private_key,
vapid_claims={"sub": "mailto:[email protected]"})
The subscription_info is the json as received while subscribing a user, vapid_private_key is the corresponding private key.