Plotly Dash plugin to allow authentication through 3rd party OAuth providers.

Overview

build

dash-auth-external

Integrate your dashboards with 3rd parties and external OAuth providers.

Overview

Do you want to build a Plotly Dash app which pulls user data from Google, Spotify, Slack etc?

Dash-auth-external provides a simple interface to authenticate users through OAuth2 code flow. Allowing developers to serve user tailored content.

Installation

Dash-auth-external is distributed via PyPi

pip install dash-auth-external

Simple Usage

#using spotify as an example
AUTH_URL = "https://accounts.spotify.com/authorize"
TOKEN_URL = "https://accounts.spotify.com/api/token"
CLIENT_ID = "YOUR_CLIENT_ID"

# creating the instance of our auth class
auth = DashAuthExternal(AUTH_URL, TOKEN_URL, CLIENT_ID)

We then pass the flask server from this object to dash on init.

app = Dash(__name__, server= auth.server)

That's it! You can now define your layout and callbacks as usual.

To obtain your access token, call the get_token method of your Auth object. NOTE This can ONLY be done in the context of a dash callback.

app.layout = html.Div(
[
html.Div(id="example-output"), 
dcc.Input(id="example-input")
])

@app.callback(
Output("example-output", "children"),
Input("example-input", "value")
)
def example_callback(value):
    token = (
        auth.get_token()
    )  ##The token can only be retrieved in the context of a dash callback
    return token

Feature Roadmap

  • OAuth2 support
  • OAuth1 support
  • Full test coverage
  • Multiple OAuth Providers
  • Support for PKCE/ non-PKCE
You might also like...
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic

OAuthLib - Python Framework for OAuth1 & OAuth2 *A generic, spec-compliant, thorough implementation of the OAuth request-signing logic for Python 3.5+

Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

This is a Python library for accessing resources protected by OAuth 2.0.

This is a client library for accessing resources protected by OAuth 2.0. Note: oauth2client is now deprecated. No more features will be added to the l

A Python library for OAuth 1.0/a, 2.0, and Ofly.

Rauth A simple Python OAuth 1.0/a, OAuth 2.0, and Ofly consumer library built on top of Requests. Features Supports OAuth 1.0/a, 2.0 and Ofly Service

The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.

Authlib The ultimate Python library in building OAuth and OpenID Connect servers. JWS, JWK, JWA, JWT are included. Authlib is compatible with Python2.

Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

Phishing Abusing Microsoft 365 OAuth Authorization Flow
Phishing Abusing Microsoft 365 OAuth Authorization Flow

Microsoft365_devicePhish Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack This is a simple proof-of-concept script that allows an at

Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack
Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack

Microsoft365_devicePhish Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack This is a simple proof-of-concept script that allows an at

Comments
  • Outdated PYPI

    Outdated PYPI

    Hi, I noticed that the master branch differs from the pypi version, when using the pypi version there is a dict error that appears which is resolved in the GitHub branch. Could you update the pypi version as well? Lastly, I keep getting a key error but as far as I can tell my token field name is correct. I am using O2Auth with openID connect.

    token = auth.get_token()
    File "auth.py", line 27, in get_token
    raise KeyError(
    KeyError: 'Header with name access_token not found in the flask request headers.'
    

    Here is my method:

    auth = DashAuthExternal(
                            external_auth_url= AUTH_URL,
                            external_token_url= TOKEN_URL,
                            client_id= CLIENT_ID,
                            with_pkce=True,
                            app_url= "http://127.0.0.1:8050",
                            redirect_suffix = "/redirect",
                            auth_suffix = "/",
                            home_suffix="/app",
                            client_secret= CLIENT_SECRET,
                            _secret_key= None,
                            auth_request_headers= None,
                            token_request_headers= None,
                            scope= ("openid profile"),
                            )
    

    Could the error be caused by anything other than an incorrect token field name?

    I also am getting this error if I try to go to /redirect after already authenticating, I am not sure if it is relevant or normal behavior after authentication.

    File "/dash_auth_external/routes.py", line 76, in build_token_body
    code = redirect_params["code"][0]
    KeyError: 'code'
    
    opened by John-LucaGIT 1
  • routes: do not override response headers

    routes: do not override response headers

    Response headers in dash-2.4 is not a dictionary but Headers. It also not ideal to override the member but amend values.

    File "/home/alonbl/.local/lib/python3.10/site-packages/flask/app.py", line 1889, in process_response response = self.ensure_sync(func)(response) File "/home/alonbl/.local/lib/python3.10/site-packages/dash/dash.py", line 1820, in _after_request response.headers.add("Server-Timing", value) AttributeError: 'dict' object has no attribute 'add'

    Signed-off-by: Alon Bar-Lev [email protected]

    opened by alonbl 0
Releases(v0.2.4)
Owner
James Holcombe
Data Science Apprentice
James Holcombe
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Welcome to django-allauth! Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (soc

Raymond Penners 7.7k Jan 3, 2023
Toolkit for Pyramid, a Pylons Project, to add Authentication and Authorization using Velruse (OAuth) and/or a local database, CSRF, ReCaptcha, Sessions, Flash messages and I18N

Apex Authentication, Form Library, I18N/L10N, Flash Message Template (not associated with Pyramid, a Pylons project) Uses alchemy Authentication Authe

null 95 Nov 28, 2022
Simplifying third-party authentication for web applications.

Velruse is a set of authentication routines that provide a unified way to have a website user authenticate to a variety of different identity provider

Ben Bangert 253 Nov 14, 2022
Mock authentication API that acceccpts email and password and returns authentication result.

Mock authentication API that acceccpts email and password and returns authentication result.

Herman Shpryhau 1 Feb 11, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Simple JWT 3.3k Jan 1, 2023
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Jazzband 3.2k Dec 29, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Jazzband 3.2k Dec 28, 2022
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.

Authlib The ultimate Python library in building OAuth and OpenID Connect servers. JWS, JWK, JWA, JWT are included. Authlib is compatible with Python2.

Hsiaoming Yang 3.4k Jan 4, 2023
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic

OAuthLib - Python Framework for OAuth1 & OAuth2 *A generic, spec-compliant, thorough implementation of the OAuth request-signing logic for Python 3.5+

OAuthlib 2.5k Jan 2, 2023
A fully tested, abstract interface to creating OAuth clients and servers.

Note: This library implements OAuth 1.0 and not OAuth 2.0. Overview python-oauth2 is a python oauth library fully compatible with python versions: 2.6

Joe Stump 3k Jan 2, 2023