flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

How to verify/check the credentials using the authorize button in Swagger UI

Open Sanket-Shinde-dev opened this issue 1 year ago • 1 comments

I'm working on a Flask-RESTful API and I'm trying to implement basic authentication using the HTTPBasicAuth class. I've included the authorizations dictionary in my API definition, but I'm encountering an issue where the credentials are not being verified when I use the "authorizationURL" parameter.

from flask import Blueprint from flask_restful import Api, HTTPBasicAuth api_v2_blueprint = Blueprint("api_v2", __name__) authorizations = { 'basicAuth': { 'type': 'basic', 'in': 'header', 'name': 'Authorization', 'authorizationUrl': 'https://xyz.com/login' } } api = Api( api_v2_blueprint, title="Api for tool1", version="2.0", description="Rest Api", authorizations=authorizations, security=authorizations ) auth = HTTPBasicAuth()

image

Expected Behavior:

I expect that the credentials should be verified by sending them to a API endpoint, and should be validated when they are added from the authorize button.

Actual Behavior:

The credentials even if they are wrong are stored when added through the "Authorize" button and when the API endpoint is hit, a browser pop-up box appears which asks for username and password again, but then upon adding the right credentials there, the wrong credentials(added via the authorize button) are sent to the API instead of new one

image

How can I use the authorize button to validate the credentials ?

Sanket-Shinde-dev avatar Nov 04 '24 11:11 Sanket-Shinde-dev

Why not use nginx for this ?

zogzog avatar Apr 12 '25 15:04 zogzog