Git Product home page Git Product logo

dash-google-auth's Introduction

Deprecation Warning

This project is no longer actively maintained and is incompatible with newer versions of Dash (>=1.0). Please consider forking this repo or see the Dash docs on officially supported authentication mechanisms.

Dash Google Auth

Dash Google Auth is a simple library using Google OAuth to authenticate and view a Dash app.

This Library uses Flask Dance and a modified version of Plotly's own dash auth for authentication.

Basic Use

Authentication can be added to your Dash application using the GoogleOAuth class, i.e.

from dash import Dash
from flask import Flask
from dash_google_auth import GoogleOAuth

server = Flask(__name__)
server.config.update({
  'GOOGLE_OAUTH_CLIENT_ID': ...,
  'GOOGLE_OAUTH_CLIENT_SECRET': ...,
})

app = Dash(__name__, server=server, url_base_pathname='/', auth='auth')

authorized_emails = [...]
additional_scopes = [...]
auth = GoogleOAuth(app, authorized_emails, additional_scopes)

# your Dash app here :)
...

Example

Steps to try this out yourself:

  1. Install the dash-google-auth library using pip:

    $ pip install dash-google-auth
  2. Follow the Flask Dance Guide to create an app on the google admin console

  3. Make a copy of app.py and set the variables (or set the corresponding environment variables):

    server.config["GOOGLE_OAUTH_CLIENT_ID"] = ...
    server.config["GOOGLE_OAUTH_CLIENT_SECRET"] = ...

    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 APIs & Services > Credentials under the section OAuth 2.0 client IDs.

  4. Replace authorized_emails in app.py with whatever Google emails you want to grant access to your app. In production, I'd recommend getting these from a database instead.

  5. 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 incognito window in this case if you want to see the login experience for a new user.

dash-google-auth's People

Contributors

lchapo avatar joshbode avatar bgweber avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.