Flask Authentication with Dash pages

Hey @MarcooPoloo and @F2P

Thanks for the pointer to the article about using flask-login with Dash - that was a helpful example.

I adapted the code in the article so that it works with the dash-labs pages plug-in . You can find the code here: GitHub - AnnMarieW/dash-flask-login: An example multi-page Dash app with Flask-Login integration

The original example had all the code in one file. I modified it so that all of the flask-login definitions and the callbacks that handle the login and log-out remained in app.py The login status is saved in a dcc.Store so it’s accessible to all the other pages which are in the pages folder. The example demonstrates requiring a login only for page-2

The biggest change is to let pages/ do it’s magic and handle the routing for you. You’ll notice that there is no need for a main router callback, and in fact dcc.Location is not used in any callback Outputs.

I hope this helps. Let me know if you have more questions :slight_smile:

7 Likes