Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyJWKError: Unable to find a algorithm for key: {'alg': 'RS256', 'kty': 'RSA', #2

Open
rene-haskia opened this issue Oct 19, 2021 · 1 comment

Comments

@rene-haskia
Copy link

I am getting this error when I try to implement this example.
The error occurs in this line in utils.py:

self.signing_key = self.jwks_client.get_signing_key_from_jwt( self.token ).key

Response:
ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Anaconda\envs\salesx\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 373, in run_asgi result = await app(self.scope, self.receive, self.send) File "C:\Anaconda\envs\salesx\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__ return await self.app(scope, receive, send) File "C:\Anaconda\envs\salesx\lib\site-packages\fastapi\applications.py", line 208, in __call__ await super().__call__(scope, receive, send) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__ raise exc File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\exceptions.py", line 82, in __call__ raise exc File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\routing.py", line 656, in __call__ await route.handle(scope, receive, send) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\routing.py", line 259, in handle await self.app(scope, receive, send) File "C:\Anaconda\envs\salesx\lib\site-packages\starlette\routing.py", line 61, in app response = await func(request) File "C:\Anaconda\envs\salesx\lib\site-packages\fastapi\routing.py", line 226, in app raw_response = await run_endpoint_function( File "C:\Anaconda\envs\salesx\lib\site-packages\fastapi\routing.py", line 159, in run_endpoint_function return await dependant.call(**values) File "main.py", line 19, in main_page result = VerifyToken(token.credentials).verify() File "C:\DEV\basf-calc-salesx\basf-calc-salesx\utils.py", line 42, in verify self.signing_key = self.jwks_client.get_signing_key_from_jwt( File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\jwks_client.py", line 59, in get_signing_key_from_jwt return self.get_signing_key(header.get("kid")) File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\jwks_client.py", line 41, in get_signing_key signing_keys = self.get_signing_keys() File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\jwks_client.py", line 28, in get_signing_keys jwk_set = self.get_jwk_set() File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\jwks_client.py", line 25, in get_jwk_set return PyJWKSet.from_dict(data) File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\api_jwk.py", line 92, in from_dict return PyJWKSet(keys) File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\api_jwk.py", line 87, in __init__ self.keys.append(PyJWK(key)) File "C:\Anaconda\envs\salesx\lib\site-packages\jwt\api_jwk.py", line 50, in __init__ raise PyJWKError("Unable to find a algorithm for key: %s" % self._jwk_data) jwt.exceptions.PyJWKError: Unable to find a algorithm for key: { 'alg': 'RS256', 'kty': 'RSA', 'use': 'sig', 'n': '6Kii4qoSGD9e<<shortened>>c11LpH3imSxhDvbh8pIs43wBpyfw', 'e': 'AQAB', 'kid': 'piKUV_SoUUczGrvSHUVzb', 'x5t': 'ACF5sviOP5RAIdM1vPec3C69VxY', 'x5c': ['MIIDDgI<<shortened>>0FFHrNNw='] }

@meisenheimere
Copy link

Try updating the Cryptography package. That worked for me.

pip install cryptography

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants