Flask-HttpAuth and Flask-Login

Victor Shelepen picture Victor Shelepen · Oct 2, 2014 · Viewed 8.1k times · Source

I am creating a small REST service. I am looking for different authentication methods. For sites I used the module Flask-Login. It seems the session authentication. The module Flask-HttpAuth provides the http and digest authentication methods. I am little bit confused. Do they complement each other? What is better to use for what is a reason?

Thank you.

Answer

Miguel picture Miguel · Oct 6, 2014

For a REST service you do not need Flask-Login. Typically in web services you do not store client state (what Flask-Login does), instead you authenticate each and every request. Flask-HTTPAuth does this for you.

You would use both only if you have an application that has a web component and a REST API component. In that case Flask-Login will handle the web app routes, and Flask-HTTPAuth will handle the API routes.

Disclaimer: I'm the author of Flask-HTTPAuth.