jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.24k stars 609 forks source link

Could not deserialize key data #593

Closed alsiPanda closed 3 years ago

alsiPanda commented 3 years ago

I have a django rest framework as my api backend(google compute engine) and flutter web in the front(localhost). My backend has no SSL or domain name. Whenever I try to send notification using device.send_message() I get the error ValueError: Could not deserialize key data. I have verified everything before this step, including the WebPushDevice . Can't figure out why I am getting this error. Does this have anything to do with not having SSL ?

dashdanw commented 3 years ago

Sounds like an issue with your webpush token, see if you can decode it yourself using pyJWT

alsiPanda commented 3 years ago

Sounds like an issue with your webpush token, see if you can decode it yourself using pyJWT

Thanks @dashdanw, a couple of doubts more here - Is the webpush token the auth value from subscription.keys or p256dh or the registration_id ? Also in pyjwt, should I use rs256 or hs256 ?

Or should I use the py_vapid.jwt and decode auth/p256dh with either auth or the private_key ?

alsiPanda commented 3 years ago

@dashdanw I am very new to push notifications, so can't figure out which one to decode, using which algorithm. Please help.

alsiPanda commented 3 years ago

Turns out the problem was in settings.py. WP_PRIVATE_KEY should be literally the key string. I had instead used path to key file.