I want to implement web push notification in django project where frontend is implemented using react. I was following https://www.digitalocean.com/community/tutorials/how-to-send-web-push-notifications-from-django-applications this documentation but i didn't find the way to get VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY for WEBPUSH_SETTINGS. What is the way to get that?
The DigitalOcean tutorial that you referred to instructs you to "navigate to the web-push-codelab web application. Here, you’ll be given automatically generated keys. Copy the private and public keys." However, it seems like this web page is no longer available.
Another way to generate a VAPID key pair is to use the web-push reference implementation. First install the web-push npm package using npm install web-push -g, then run web-push generate-vapid-keys to get an output like:
Public Key:
BLEvwbQgAjaHjmXcJgpAmOpFCuR-m_BKJWhskZmbFYAQABA4ZrpLQ1UnNJVH_Zbmzjugmmts2I5kLt8wMKQlIME
Private Key:
cSTj1YJCOQGP-J6QLCr3gSkU2OPs39Dx3FtiBc6ZOYI
Obviously, do not use this key pair -- you're supposed to keep your private key, well.., private.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With