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-authlibrary 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_emailsinapp.pywith 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.pyand 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.
Metadata
Release files for dash-google-auth 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dash_google_auth-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for dash_google_auth-0.1.2-py3-none-any.whl |
Release files / dash_google_auth-0.1.2-py3-none-any.whl
| Download URL | dash_google_auth-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea74099e9d9102a3aee850330e9e208d7a5cf6f14159f9c11324b66f40338cfc
|
|
BLAKE2b-256 checksum How to use checksums |
485cb39371b5b7ee976463e91f6aef0ea719b903bed26eb3bba0f32b675bc166
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for dash-google-auth 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.