-1

I am using python jwt to get a jwt token using algorithm RS512, but I keep getting error that algorithm is not found. Also, I get an error that no cryptography component is found. I have installed pycryptodome though.

Can anyone help on resolving above issues? Below is my code:

def generate_jwt_token(self):
 privateKeyPath = './config/privateKey.pem'
 payload = {'name': 'abc'}
 with open(privateKeyPath ,'rb') as f:
 privateKey = f.read()
 jwtToken = jwt.encode(payload, key=privateKey, algorithm='RS512')
 print(jwtToken)
Brian Tompsett - 汤莱恩
5,92772 gold badges64 silver badges135 bronze badges
asked Apr 17, 2024 at 15:47
1
  • error "do you Cryptography component is installed" - I doubt that this is the error message that you got. Please edit your question to add the precise error message. Commented Apr 17, 2024 at 16:01

1 Answer 1

0

Got the answer for algorithm not found :- Instead of installing pycrypto or pycryptodome, install the crypto component along with jwt. pip install pyjwt[crypto]

answered Apr 17, 2024 at 15:49
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.