Authenticating using the Flask-Login extension

In our previous recipe, we learned how to implement session-based authentication ourselves. Flask-Login is a popular extension that handles a lot of stuff for us in a very good way, saving us from reinventing the wheel all over again. It also does not bind us to any specific database or limit us to any specific fields/methods for authentication. It can also handle the Remember me feature, account recovery features, and so on.

Getting ready

We can modify the application created in the previous recipe to accommodate the changes to be done by the Flask-Login extension.

Before that, we have to install the extension itself:

$ pip install Flask-Login

How to do it…

To use Flask-Login, we have to first modify ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.