FastAPI - Authentication and Security
Why does this FastAPI code raise an error when handling Bearer tokens?
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@app.get("/profile")
async def profile(token: str = Depends(oauth2_scheme)):
if not token:
return {"error": "No token"}
return {"token": token}