Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Error : Web push send from python backend

未关闭
#149 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
backend

调研方向

Start with the shown webpush call, private_key.pem input, subscription object, and Python base64 traceback, then reproduce the failure using the supplied values. Done means identifying the source of the incorrect-padding error and documenting the required input format or a precise fix.

由索引模型根据 Issue 内容生成。

描述

Hello, I'm having a problem when I try to run a notification, I think I'm following the documentation to the letter.

Information

Keys generated with vpaid (python): https://github.com/web-push-libs/vapid/tree/main/python

  • The keys that I indicate are for testing...

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?

主要语言
Python
星标
379
派生
61
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

web-push-libs/pywebpush 的其他 Issue

查看 web-push-libs/pywebpush 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。