Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY for django webpush implementation?

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?

like image 280
Faria Nawrine Avatar asked Dec 10 '25 07:12

Faria Nawrine


1 Answers

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.

like image 195
Martijn Avatar answered Dec 12 '25 23:12

Martijn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!