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
bucky barns
3958 silver badges19 bronze badges
-
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.jps– jps2024年04月17日 16:01:53 +00:00Commented Apr 17, 2024 at 16:01
1 Answer 1
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
bucky barns
3958 silver badges19 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py