[英]How to set username and password for basic auth in flask restx swagger?
Im trying to add basic Authorization to my flask rest-x application.我正在尝试向我的 flask rest-x 应用程序添加基本授权。 By referring to https://github.com/python-restx/flask-restx/issues/271 I have made code changes.
参考https://github.com/python-restx/flask-restx/issues/271我做了代码修改。
But here there is no clarity on how to set and a username and password.但是这里并没有明确说明如何设置用户名和密码。 As well in the swagger UI i see the login for basic auth happens with any username and password.
同样在 swagger 用户界面中,我看到基本身份验证的登录使用任何用户名和密码。
I have tried searching multiple resources but could not get a way how to set username & password and authenticate it.我曾尝试搜索多个资源,但无法找到如何设置用户名和密码并对其进行身份验证的方法。 Please help regarding the same.
请帮忙解决同样的问题。
Flask restx version: 0.5.1
try the following code试试下面的代码
from flask_restx import Api
blueprint = Blueprint("api", __name__)
authorizations = {
"Authorization": {
"description": "Inputs: Basic \\email\\>",
"type": "apiKey",
"in": "header",
"name": "Authorization",
}
}
api = Api(
blueprint,
title="Dummy API",
version="1.0",
authorizations=authorizations,
security="Authorization",
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.