Looking for some guidance. I've used pyJWT before and had no issues, but recently moved over to a Mac so I'm wondering if its something with the environment variables I don't know to check. Using Python 3.9, PyCharm and a virtual environment.
Trying to create a JWT, encode it to RS384 algorithm (which is supported according to the documentation at https://pyjwt.readthedocs.io/en/latest/algorithms.html and has worked previously on a Windows Machine).
Created my virtual environment, used PIP3 to install pyJWT and received the error "NotImplementedError: Algorithm 'RS384' could not be found. Do you have cryptography installed?".
I was under the impression that pyJWT would download dependencies but even so I downloaded cyrptography and it still appears to have the issue. I've checked my pip3 list as well as my pyCharm libraries for the virtual environment and everything appears good. Any suggestions on what is going on?
Even the simplest sample code (below) receives this error
Code Sample
import jwt
encoded = jwt.encode({"some": "payload"}, "secret", algorithm="RS384")
print(encoded)
-
1even if you follow the answer below and get all dependencies sorted, the next error will be about your key. You can't just use a simple string, as you might have used before for HS256, as a key for ES384. You need a real ES384 private key instead.jps– jps2022年06月22日 19:09:16 +00:00Commented Jun 22, 2022 at 19:09
-
Thanks for the info. I was previously using a .pem file I was reading in my Windows project. I was just trying to make it the simplest example possible to rule out other issues, but will note that. Thank you.sallou– sallou2022年06月22日 20:47:47 +00:00Commented Jun 22, 2022 at 20:47
1 Answer 1
Install the PyJWT cryptographic dependencies. Keep in mind that zsh uses square brackets for globbing / pattern matching. That means that if you need to pass literal square brackets as an argument to a command, you either need to escape them or quote the argument like this:
pip3 install 'pyJWT[crypto]'