I am trying to use the EdDSA algorithm for encoding but I keep getting the below error.
Any ideas as to what I am doing wrong?
EllipticCurvePrivateKey = "-----BEGIN PRIVATE KEY-----\[HIDDEN]\n-----END PRIVATE KEY-----"
encoded = jwt.encode({"some": "payload"}, EllipticCurvePrivateKey, 'EdDSA')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/rogermukai/Dev/Templates/jwt-example/.venv/lib/python3.10/site-packages/jwt/api_jwt.py", line 67, in encode
return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
File "/Users/rogermukai/Dev/Templates/jwt-example/.venv/lib/python3.10/site-packages/jwt/api_jws.py", line 153, in encode
key = alg_obj.prepare_key(key)
File "/Users/rogermukai/Dev/Templates/jwt-example/.venv/lib/python3.10/site-packages/jwt/algorithms.py", line 601, in prepare_key
raise InvalidKeyError(
jwt.exceptions.InvalidKeyError: Expecting a EllipticCurvePrivateKey/EllipticCurvePublicKey. Wrong key provided for EdDSA algorithms
I am expecting to be able to use the EdDSA algorithm as the documentation states that it is possible but it gives no examples.
Here is how I figured it out. I ran the below steps in order from top to bottom.
In the terminal/sehlll:
In python