pywebpush
pywebpush copied to clipboard
Authentication failling on Firefox and Chrome
Hey,
Thank you for the work on this lib.
I'm currently not able to post push notifications to firefox and chrome as the example shows. Both give me authentication error.
Settings:
chrome_demo = {
"subscription_info": {
"endpoint": "https://fcm.googleapis.com/fcm/senddSbTwHYXBxQ:APA91bFjU7L9Vs09sDCJc_H5QhuZqASMTrW7jYUM70xahdJ1Bj8tDPSJDlOd_2_MeyWJbgLK1dmOxvGmovX2t-JUqR7Va7MT4XugEQk_mzhQw1Ko8l3wRpUAyImbSVeD8kVfxfK-cDe0",
"expirationTime": None,
"keys": {
"p256dh": "BGOQdDEJw-7M7Cpa56qiqNau9U00gB3Ik-jSeAdm0WRwpBeS6qUXJhaJ7cTPkjj7qRYI0cS2KEy1OSia6S-By1k",
"auth": "Ehjdbe-3rFnHW9p92Mvkjg"
}
},
"headers": {
"TTL": "60",
"Content-Length": "0",
"Authorization": "vapid t=eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL2ZjbS5nb29nbGVhcGlzLmNvbSIsImV4cCI6MTYwMTc4NjM5MSwic3ViIjoibWFpbHRvOnNpbXBsZS1wdXNoLWRlbW9AZ2F1bnRmYWNlLmNvLnVrIn0.5Djt0lsmwIJhvf7Mx5aw8gIwgJGBzP23LTAP8f_DCO_sWDFXD4dYn6ZkpLgudxtGJWOT5pz86D6mQpHXa9iofQ, k=BDd3_hVL9fZi9Ybo2UUzA284WG5FZR30_95YeZJsiApwXKpNcF1rRPF3foIiBHXRdJI2Qhumhf6_LFTeZaNndIo",
}
}
Call:
webpush(
subscription_info=subscription_info,
data=data,
vapid_private_key=vapid_private_key,
verbose=True,
#vapid_claims={"sub": "mailto:[email protected]"},
headers=headers
)`
The results are:
`Sending request to
host: https://fcm.googleapis.com/fcm/send/dSbTwHYXBxQ:APA91bFjU7L9Vs09sDCJc_H5QhuZqASMTrW7jYUM70xahdJ1Bj8tDPSJDlOd_2_MeyWJbgLK1dmOxvGmovX2t-JUqR7Va7MT4XugEQk_mzhQw1Ko8l3wRpUAyImbSVeD8kVfxfK-cDe0
headers: {'ttl': '60', 'content-length': '0', 'authorization': 'vapid t=eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL2ZjbS5nb29nbGVhcGlzLmNvbSIsImV4cCI6MTYwMTc4NjM5MSwic3ViIjoibWFpbHRvOnNpbXBsZS1wdXNoLWRlbW9AZ2F1bnRmYWNlLmNvLnVrIn0.5Djt0lsmwIJhvf7Mx5aw8gIwgJGBzP23LTAP8f_DCO_sWDFXD4dYn6ZkpLgudxtGJWOT5pz86D6mQpHXa9iofQ, k=BDd3_hVL9fZi9Ybo2UUzA284WG5FZR30_95YeZJsiApwXKpNcF1rRPF3foIiBHXRdJI2Qhumhf6_LFTeZaNndIo', 'content-encoding': 'aes128gcm'}
And it works, I receive the notification.
But if I use the vapid_claims sub and the headers are generated by the lib I get an authentication error as seen bellow.
Call:
webpush(
subscription_info=subscription_info,
data=data,
vapid_private_key=vapid_private_key,
verbose=True,
vapid_claims={"sub": "mailto:[email protected]"},
)`
Request:
`Sending request to
host: https://fcm.googleapis.com/fcm/send/dSbTwHYXBxQ:APA91bFjU7L9Vs09sDCJc_H5QhuZqASMTrW7jYUM70xahdJ1Bj8tDPSJDlOd_2_MeyWJbgLK1dmOxvGmovX2t-JUqR7Va7MT4XugEQk_mzhQw1Ko8l3wRpUAyImbSVeD8kVfxfK-cDe0
headers: {'authorization': 'vapid t=eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL2ZjbS5nb29nbGVhcGlzLmNvbSIsImV4cCI6MTYwMTc4Nzg5OSwic3ViIjoibWFpbHRvOllvdXJOYW1lSGVyZUBleGFtcGxlLmNvbSJ9.3kcfLFbe9n39wWy4Conww-nsTfuir_C-bH8aBNxctJztRHM1DijpkkhWc8Irg_eyeJUa-HHf0de2qFUfLbSGlg,k=BLhZbKpoVZdim51j3JJWUyuvuLGDubVBoO7e7tvhj-fW7oFrp5SV3F9kbKeiayL1YhgEBYQ2UWdJY-GwGlKyFU0', 'content-encoding': 'aes128gcm', 'ttl': '0'}
On Firefox I have a similar.
I used this site to test https://gauntface.github.io/simple-push-demo/.
Am I doing something wrong? Why am I getting the authorization field wrong?
Thank you for the support.