-
Notifications
You must be signed in to change notification settings - Fork 0
JWT Token
Marc Szymkowiak edited this page May 12, 2022
·
2 revisions
To secure an endpoint with an jwt token just use the the following decorator in your controller
@token_required
In addition, swagger-ui must be informed that an API key is required for this endpoint. For this we add the parameter security with the value apikey to the doc decorator
@api.doc("list_of_registered_users", security="apikey")
Example: To secure the api endpoint to get a list of all registered users in controller/user.py
@api.doc("list_of_registered_users", security="apikey")
@api.marshal_list_with(_user, envelope="data")
@token_required
def get(self):
"""List all registered users"""
return get_all_users()