Closed BorjaEst closed 1 year ago
In case someone wonders why not to remove user_infos
, I think (by reading the docs) it is a required field. If I remove:
@app.get("/info")
@flaat.inject_user_infos() # Fail if no valid authentication is provided
def info_strict_mode(request: Request):
return <something>
Then I get info_strict_mode() got an unexpected keyword argument 'user_infos'
as the function does not accept such argument.
It's funny, it seems to work if you change the name of the key that is injected:
@app.get("/info")
@flaat.inject_user_infos(key="userinfo") # Fail if no valid authentication is provided
def info_strict_mode(request: Request, userinfo=None):
return userinfo.toJSON()
Thanks @dianagudu
Yes, that is an option, however it might affect the generated Swagger docs. In case a user needs them, it is probably better to get the user_infos from the request.
I have updated the example, so I am closing the issue.
I am unable to create a first example injecting user_infos:
When calling the enpoint using a correct token, I get
Internal Server Error
due tocheck_request_authorization() got multiple values for argument 'user_infos'
. Maybe I am missing something?