close

[Solved] Could not deserialize key data on decoding JWT python

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Could not deserialize key data on decoding JWT python in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Could not deserialize key data on decoding JWT python Error Occurs?

Today I get the following error Could not deserialize key data on decoding JWT python in python.

How To Solve Could not deserialize key data on decoding JWT python Error ?

  1. How To Solve Could not deserialize key data on decoding JWT python Error ?

    To Solve Could not deserialize key data on decoding JWT python Error There are some issues in the pyjwt library. and you must get the public key from the certificate.

  2. Could not deserialize key data on decoding JWT python

    To Solve Could not deserialize key data on decoding JWT python Error There are some issues in the pyjwt library. and you must get the public key from the certificate.

Solution 1

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)

Solution 2

Its a good idea to use your RSA keys with OpenSSL:

openssl genrsa -out jwt-key 4096
openssl rsa -in jwt-key -pubout > jwt-key.pub

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read