pyjwt
pyjwt copied to clipboard
Not support RS256 algorithm?
Codes:
Return:
It is supported. Make sure you have cryptography installed.
https://pyjwt.readthedocs.io/en/stable/installation.html#cryptographic-dependencies-optional
If crypto is not installed, RS256 will not be in your default algorithms list: https://github.com/jpadilla/pyjwt/blob/5ecbafc366ebc4940ce4eac81350bc41887a4433/jwt/algorithms.py#L79-L104
Also your installation may be older as line 272 in api_jws.py is not the raise InvalidAlgorithmError...
: https://github.com/jpadilla/pyjwt/blob/master/jwt/api_jws.py#L272
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
I'm still getting this issue:
Traceback (most recent call last):
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jws.py", line 88, in get_algorithm_by_name
return self._algorithms[alg_name]
KeyError: 'RS256'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jws.py", line 295, in _verify_signature
alg_obj = self.get_algorithm_by_name(alg)
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jws.py", line 91, in get_algorithm_by_name
raise NotImplementedError(
NotImplementedError: Algorithm 'RS256' could not be found. Do you have cryptography installed?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 55, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/justin/Documents/dev/bwwc/backend/backend/apis/bwwc.py", line 26, in start_session
auth.verify_token(auth_token, public_key)
File "/Users/justin/Documents/dev/bwwc/backend/backend/apis/auth.py", line 40, in verify_token
payload = jwt.decode(token, public_key, algorithms=[self.jwt_algorithm])
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jwt.py", line 168, in decode
decoded = self.decode_complete(
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jwt.py", line 120, in decode_complete
decoded = api_jws.decode_complete(
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jws.py", line 202, in decode_complete
self._verify_signature(signing_input, header, signature, key, algorithms)
File "/Users/justin/.pyenv/versions/ml/lib/python3.10/site-packages/jwt/api_jws.py", line 297, in _verify_signature
raise InvalidAlgorithmError("Algorithm not supported") from e
jwt.exceptions.InvalidAlgorithmError: Algorithm not supported
For those who will have this problem, try to install cryptography
package.
I have this problem when I migrating to poetry and I won't knew all deps my project has.