Basic example of using Google OAuth to authenticate and view a Dash app. Uses flask dance and a modified version of Plotly's own dash auth for authentication.
Steps to try this out yourself (after installing requirements):
- Follow the Flask Dance Guide to create an app on the google admin console
- Replace the variables for app.server.config["GOOGLE_OAUTH_CLIENT_ID"] and app.server.config["GOOGLE_OAUTH_CLIENT_SECRET"] in init.py with values from the Google OAuth 2 client you should have set up in step 1
- Replace authorized_emails from init.py with whatever google authenticated emails you want to test with. You could also get these from a database.
- Run
python app.py
and open localhost in a browser window to try it out! Dash uses port 8050 by default, so if you haven't changed this you'd want to go here If the app loads automatically without prompting a google login, that means you're already authenticated -- try using an incogntio window in this case if you want to see the login experience for a new user.