Endpoints with authentication in debug mode #504
-
I have some endpoints that require authentication, and haven't found a way to test them through the web interface http://localhost:5000/docs Is there a convenient way, something like Maybe this could be added to the docs/tutorials ? Btw great work, it's a very nice library ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
A simple example here: from apiflask import APIFlask, Schema
from apiflask.fields import String
app = APIFlask(__name__)
class WithAuth(Schema):
token = String(required=True)
@app.post("/permissions")
@app.input(WithAuth, location="headers")
def foo(headers_data):
print(headers_data)
return {"err_code": "", "msg": "", "res": None}
app.run() Then visit You can populate your token here. Click on And what you may be interested in: request-locations. |
Beta Was this translation helpful? Give feedback.
A simple example here:
Then visit
http://127.0.0.1:5000/docs
, and try it out:You can populate your token here. Click on
execute
btn, what you get in your terminal will be a string looked like{'token': 'xxxx'}
. 🥂And what you may be interested in: request-locations.