3

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

rakesh kotian
  • 232
  • 1
  • 5
  • 30

1 Answers1

0

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",
)
Hashir Irfan
  • 315
  • 1
  • 9