fief-dev / fief-python

Fief client for Python
https://docs.fief.dev/integrate/python/
MIT License
12 stars 4 forks source link

You are trying to JSON Parse a 301 body... FastAPI /docs: jwcrypto.jwk.InvalidJWKValue #5

Closed StephanMeijer closed 1 year ago

StephanMeijer commented 1 year ago
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/jwcrypto/jwk.py", line 1329, in import_keyset
    jwkset = json_decode(keyset)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/jwcrypto/common.py", line 42, in json_decode
    return json.loads(string)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
    raise exc
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
    await self.app(scope, receive, sender)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/routing.py", line 680, in __call__
    await route.handle(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/routing.py", line 275, in handle
    await self.app(scope, receive, send)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fastapi/routing.py", line 221, in app
    solved_result = await solve_dependencies(
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fastapi/dependencies/utils.py", line 533, in solve_dependencies
    solved = await call(**sub_values)
  File "<makefun-gen-0>", line 2, in _authenticated
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fief_client/integrations/fastapi.py", line 175, in _authenticated
    info = await result
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fief_client/client.py", line 864, in validate_access_token
    jwks = await self._get_jwks()
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/fief_client/client.py", line 989, in _get_jwks
    self._jwks = jwk.JWKSet.from_json(response.text)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/jwcrypto/jwk.py", line 1353, in from_json
    obj.import_keyset(keyset)
  File "/Users/steve/PycharmProjects/Taskwarrior-box/venv/lib/python3.9/site-packages/jwcrypto/jwk.py", line 1331, in import_keyset
    raise InvalidJWKValue from e
jwcrypto.jwk.InvalidJWKValue
StephanMeijer commented 1 year ago
image
frankie567 commented 1 year ago

Sorry, but posting stack traces without any explanation is not very helpful.

You should show relevant parts of your code and explain what you're trying to do so we can help.

For questions like this, please post them on our GitHub Discussions.