fief-dev / fief-python

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

Handle FiefRequestError gracefully in current_user integrations #12

Open frankie567 opened 1 year ago

frankie567 commented 1 year ago

Currently, in the current_user functions from FastAPI/Flask/CLI integrations, we assume the token is valid and thus that the request to Fief will succeed.

However, there might be cases where the client considers the token as valid, but the Fief server does not. Typically, if we change our token structure and the client is outdated, the client will accept it but the server will reject.

We should handle this case more gracefully by raising a proper Unauthorized error when this happens.