-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error : Web push send from python backend #149
Comments
@jrconlin any ideas what I may be doing wrong? I am blocked and the only solution I would have would be to integrate in node that I have seen that I have no problem. |
Hrm, On my system, your private key is invalid. If that was generated by vapid, I'm not sure why it made an invalid key, but you can also create one by using openssl directly:
I'm also not sure why you're seeing the |
Thanks, I'll try again as you say. |
Thanks, finally without generating the keys through the vapid library I got it to work. I found these commands that I think could be useful for people who want to work with DER (bas64), I'll leave it here:
Thank @jrconlin |
Hello, I'm having a problem when I try to run a notification, I think I'm following the documentation to the letter.
Information
PrivateKey [private_key.pem]
----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg4zLDHdp8DtxtcAO4
MZVGeyp2JLJyVrqaMII75nGeAC+hRANCAATW1506jo86/0Ek72wj/AYgGZ6d1R3i
wabGfNb7DlMSmIrdYbrgLLI6HgnszgCGM1ORilZ95RoW9x0ER8+h8SI2
-----END PRIVATE KEY-----
ApplicationServerKey:
BNbXnTqOjzr_QSTvbCP8BiAZnp3VHeLBpsZ81vsOUxKYit1huuAssjoeCezOAIYzU5GKVn3lGhb3HQRHz6HxIjY
Subscription (chrome client: successfully generated with the ApplicationServerKey):
{"endpoint":"https://fcm.googleapis.com/fcm/send/eN9gFAJxIeA:APA91bGRifdlYB8pDgJ9wEYNxxIrVkT5Lb2cNTvtiU55-0bFmV4KGVBuIYbk67NRPjflK4FFdA5tJBPtHVaMMV0IzLrDvBtpBy1cd5VDzrKjXbBN5rJ5NWF-RurzHaFX2iBiun_ypzCT","expirationTime":null,"keys":{"p256dh":"BD9sOH3XIEbgk1x_KvtLbCLvyYEnuQ972W4LaTUnvl_-7vB_q8IzToFKGWK_QaTtUhWBj-Tb556xPuR9uXmr6-E","auth":"X0Zy2i_2WC3tkjElaK3D2g"}}
Code
webpush(
vapid_private_key="private_key.pem",
vapid_claims={"sub": "mailto:[email protected]"},
subscription_info=subscription,
data=data
)
Error
...
return base64.urlsafe_b64decode(data + b"===="[len(data) % 4:])
File "/usr/lib/python3.8/base64.py", line 133, in urlsafe_b64decode
return b64decode(s)
File "/usr/lib/python3.8/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
@jrconlin Could you tell me what I may be doing wrong?
The text was updated successfully, but these errors were encountered: