亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從斷言中解碼 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 關注
  • 357 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號