Could not deserialize key data on decoding JWT python

前端 未结 7 1033
日久生厌
日久生厌 2021-01-02 07:51

I am using pyjwt library for decoding the JWT token. I got this error when I am decoding. The code was given in the documantation.

import jwt

encoded_jwt=\'         


        
7条回答
  •  情歌与酒
    2021-01-02 08:36

    There are some issues in the pyjwt library. and you must get the public key from the certificate.

    I used openssl x509 -pubkey -noout -in cert.pem > pubkey.pem

    then from the public key I could easily decode it using authlib library.

    from authlib.specs.rfc7519 import jwt
    
    encoded_jwt='''eyJ0eXAiOiJ....'''
    secret=b'''-----BEGIN PUBLIC KEY-----
    ......
    -----END PUBLIC KEY-----'''
    claims = jwt.decode(encoded_jwt, secret)
    print(claims)
    

提交回复
热议问题