Dash Google Auth
Project description
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:
-
Install the
dash-google-auth
library usingpip
:$ pip install dash-google-auth
-
Follow the Flask Dance Guide to create an app on the google admin console
-
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.
-
Replace
authorized_emails
inapp.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 incognito window in this case if you want to see the login experience for a new user.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file dash_google_auth-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: dash_google_auth-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea74099e9d9102a3aee850330e9e208d7a5cf6f14159f9c11324b66f40338cfc |
|
MD5 | 2b08a227109547cba72bf1c94ce83ce8 |
|
BLAKE2b-256 | 485cb39371b5b7ee976463e91f6aef0ea719b903bed26eb3bba0f32b675bc166 |