Can't create optionally authenticated path in FastAPI #150
-
I'm trying to create an api route where you can be authenticated, but you don't have to. According to the docs, I can just add "optional=True" inside the authenticated call inside the Depends(), however I'm still getting "401 Unauthorized" and none of my code is being run. The function also works if i comment out the access_token_info stuff. Code below: Sorry if I'm missing something simple |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hail, @kschniedergers 👋 Welcome to Fief's kingdom! Our team will get back to you very soon to help. In the meantime, take a minute to star our repository ⭐️ Farewell! |
Beta Was this translation helpful? Give feedback.
-
Hey @kschniedergers 👋 It looks like you're using FastAPI. Did you make sure to set scheme = OAuth2AuthorizationCodeBearer(
"https://example.fief.dev/authorize",
"https://example.fief.dev/api/token",
scopes={"openid": "openid", "offline_access": "offline_access"},
auto_error=False, # 👈 That's important
) |
Beta Was this translation helpful? Give feedback.
Hey @kschniedergers 👋
It looks like you're using FastAPI. Did you make sure to set
auto_error=False
to thescheme
: