为了账号安全,请及时绑定邮箱和手机立即绑定

从断言中解码 JWT - Google 登录

从断言中解码 JWT - Google 登录

鸿蒙传说 2021-07-12 17:07:11
我正在尝试在 Actions on Google 中实现帐户链接(使用此)我被困在其中的处理自动链接步骤。assertion当我尝试使用此处指定的python-jose库对其进行解码时,我收到了请求!from jose import jwtkey = "728f4016652079b9ed99861bb09bafc5a45baa86" # PUBLIC KEY OF GOOGLE from https://www.googleapis.com/oauth2/v3/certsencoded = "ENCODED_ASSERTION"decoded = jwt.decode(encoded, key, algorithms='RS256')print (decoded)当我运行此代码时,它显示Traceback (most recent call last):File "/Users/jay.patel/env372/lib/python3.7/site-packages/jose/backends/pycrypto_backend.py", line 72, in __init__    self.prepared_key = RSA.importKey(key)  File "/Users/jay.patel/env372/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py", line 757, in import_key    raise ValueError("RSA key format is not supported")ValueError: RSA key format is not supportedDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "/Users/jay.patel/PycharmProjects/Prac/jwt.py", line 19, in <module>    decoded = jwt.decode(encoded, key, algorithms='RS256')  File "/Users/jay.patel/env372/lib/python3.7/site-packages/jose/jwt.py", line 135, in decode    payload = jws.verify(token, key, algorithms, verify=verify_signature)  File "/Users/jay.patel/env372/lib/python3.7/site-packages/jose/jws.py", line 77, in verify    _verify_signature(signing_input, header, signature, key, algorithms)  File "/Users/jay.patel/env372/lib/python3.7/site-packages/jose/jws.py", line 264, in _verify_signature    if not _sig_matches_keys(keys, signing_input, signature, alg):我究竟做错了什么??我刚刚使用了 RS256,因为它是在 Google 的公钥中指定的(以JWK或PEM格式提供)PS 当我尝试使用算法解码此处的断言时,RS256它显示无效签名错误,如下图所示。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 333 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号