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 server.config["GOOGLE_OAUTH_CLIENT_ID"] and 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. If you've set these up properly, you can find them at https://console.developers.google.com/apis/credentials under the section OAuth 2.0 client IDs
- Replace authorized_emails from init.py with whatever google emails you want to grant access to your app. In production, I'd recommend getting these from a database instead.
- Run
python app.py
and open localhost in a browser window to try it out! 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.