'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. By referring to https://github.com/python-restx/flask-restx/issues/271 I have made code changes.
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.
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
Solution 1:[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",
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hashir Irfan |
