Skip to content

Endpoints with authentication in debug mode #504

Answered by tkzt
sylvain-ri asked this question in Q&A
Discussion options

You must be logged in to vote

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 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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sylvain-ri
Comment options

Answer selected by greyli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #503 on November 12, 2023 14:55.