Comments (15)
I am a little confused. The browser displays the standard username/password dialog box any time a HTTP request ends with a 401.
What would you like to happen instead?
from flask-restful.
Gah, you know what it's pretty late over here and I wasn't thinking straight. Closing this. Thanks for pointing out the obvious.
from flask-restful.
Actually it's not the 401 that triggers the browser auth dialog, but the WWW-Authenticate header from:
https://github.com/twilio/flask-restful/blob/master/flask_restful/utils/__init__.py#L16
It would be nice to have this configurable because not everyone is using HTTP Basic auth. I monkey patch this out in my app so that I can do API testing in the browser more easily.
from flask-restful.
Actually yea I think this is true -- if the auth header was removed the browser wont attempt to ask for a username/password.
from flask-restful.
In your testing, could you just override the unauthorized method with a no-op method?
I'm still a little unclear on what you actually want to configure here.
from flask-restful.
Closing because @kevinburke's fix seems simple enough and there's been no discussion on this in a month.
from flask-restful.
I've failed to see any mention in the documentation that this is the default behavior or how to change it. In my case, I don't want to send basic authentication headers to the client. I'd like to render a response with a message in it stating the client was unauthorized. Is this at all possible without having to extend the Api
class?
from flask-restful.
+1 on this, I'm hitting some very odd issues because I'm trying to implement digest auth, and it's colliding with restful's basic auth header.
from flask-restful.
I would even go as far as to be able to tell Flask-Restful to not handle errors at all.
from flask-restful.
+1
from flask-restful.
+1 Very annoying when using the combining in a single flask app a restful API and a web app. May be Flask-security could have a @reject_unlogged decorator (would raise a 401 directly) in addition to @login_required (that prompt the auth form).
from flask-restful.
+1
from flask-restful.
+1
from flask-restful.
+1
from flask-restful.
For now, please try the workaround suggested by @dougblack here.
I think this will be taken care of once a better custom error handler system is implemented (see #274, #284, etc). I'd like to implement it similar to the standard flask @app.error_handler
method, i.e. an @api.error_handler
that accepts HTTP status codes or exceptions. It would be populated with a few defaults to keep consistent with the way it works now, but those would be easily overridable in a way that wont require you to subclass Api
.
from flask-restful.
Related Issues (20)
- how to get request.files attribute after flask send_from_directory?
- Return custom error code HOT 1
- Swagger doc like FastAPI HOT 2
- Did not attempt to load JSON data because the request Content-Type was not 'application/json'. HOT 8
- Is expected behavior of flask_restful abort() correct ? HOT 1
- Question: optional/wildcard url parameter HOT 1
- Flask 2.3 Incompatibility: app.propagate_exceptions is depreciated HOT 1
- test_client.get() with query_string doesn't work HOT 1
- The app.propagate_exceptions will be deprecated in Flask 2.3
- Using reqparse.add_argument() with default location parameter to parse requests with Content-Type other than "application/json" raises an exception when using Werkzeug>=2.1.0 HOT 3
- @api.resource is used in blueprint that it is not working HOT 1
- test_redirect failure HOT 1
- sdist is missing `tox.ini`
- This is alive? HOT 1
- response header "Server' cannot modified
- Is flask-restful dead? HOT 2
- Questions about Copilot + Open Source Software Hierarchy
- Documentation out of date for compatible Python versions
- Flask-RESTful breaks with Flask 2.3 and newer HOT 1
- Frontlight debug issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-restful.