Giter Club home page Giter Club logo

Comments (15)

kevinburke avatar kevinburke commented on September 23, 2024

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.

robertjpayne avatar robertjpayne commented on September 23, 2024

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.

noise avatar noise commented on September 23, 2024

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.

robertjpayne avatar robertjpayne commented on September 23, 2024

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.

kevinburke avatar kevinburke commented on September 23, 2024

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.

dougblack avatar dougblack commented on September 23, 2024

Closing because @kevinburke's fix seems simple enough and there's been no discussion on this in a month.

from flask-restful.

mattupstate avatar mattupstate commented on September 23, 2024

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.

malicustommade avatar malicustommade commented on September 23, 2024

+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.

mattupstate avatar mattupstate commented on September 23, 2024

I would even go as far as to be able to tell Flask-Restful to not handle errors at all.

from flask-restful.

moritzg91 avatar moritzg91 commented on September 23, 2024

+1

from flask-restful.

DerekDomino avatar DerekDomino commented on September 23, 2024

+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.

rbpasker avatar rbpasker commented on September 23, 2024

+1

from flask-restful.

phalgun avatar phalgun commented on September 23, 2024

+1

from flask-restful.

andressrg avatar andressrg commented on September 23, 2024

+1

from flask-restful.

joshfriend avatar joshfriend commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.