我正在尝试向浏览器发送推送通知,不幸的是,请参见下面的脚本,它始终失败:pywebpush.WebPushException: WebPushException: Push failed: 403 MismatchSenderId
关于如何解决此问题的任何想法?使用javascript发送时,它可以处理相同的数据。
import pytest
from pywebpush import webpush
@pytest.fixture()
def subs():
return {'expirationTime': None,
'keys': {'p256dh': 'BDz4O5Lb96W133iNj7uEmN0nnZuCDQKg8DTqa4P50stLUJ0vXBhwLker4EyMtf_U2Hr-UFf084QCxwZSR_3F70A',
'auth': 'JyE37R0w1dNBzuNYFG7FMA'},
'endpoint': 'https://fcm.googleapis.com/fcm/send/cvNVGGLtZVo:APA91bFqfRXSHhqdzv6MXFKu7SFUvqyPSRlSNxER2B9cIj5OQZAC1THzACTgtg5Ig6RJiVxhVxL49DrOulNsDv6SkK_DwnnGOs4BVIErOOrNgD9kemuRMaft4n-mwlaptN9ZTNuG6mM2'}
@pytest.fixture()
def vapid_data():
return {
"subject": "mailto:tech@rect.ag",
"publicKey": "BEtyWjkXAXTOTN-5X018konhbR5KpAaQbM4jcWptLDzO2Ia-tm93NCY72TMh5kYAjYDThYY40FGh2BFHJeSX-04",
"privateKey": "Ew2kli-56Ps6FEspgshs9MnFhhuX2mlMdXqhZqisN5w"
}
def test_push(subs, vapid_data):
webpush(subs,
'Your Push Payload Text',
vapid_private_key=vapid_data['privateKey'],
vapid_claims={"sub": "mailto:tech@rect.ag"},
ttl=2419200,
)