dash-auth-external
Integrate your dashboards with 3rd party APIs and external OAuth providers.
Overview
Do you want to build a Plotly Dash app which pulls user data from external APIs such as 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
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
token_data = auth.get_token_data()
# get_token_data can be used to access other data returned by the OAuth Provider
print(token)
print(token_data)
return token
Results in something like:
>>> fakeToken123
>>> {
"access_token" : "fakeToken123",
"user_id" : "lucifer",
"some_other_key" : 666,
"expires_at" : "judgmentDay"
}
Refresh Tokens
If your OAuth provider supports refresh tokens, these are automatically checked and handled in the get_token method.
Check if your OAuth provider requires any additional scopes to support refresh tokens
Troubleshooting
If you hit 400 responses (bad request) from either endpoint, there are a number of things that might need configuration.
Make sure you have checked the following
- Register your redirect URI with OAuth provider!
The library uses a default redirect URI of http://127.0.0.1:8050/redirect.
Contributing
Contributions, issues, and ideas are all more than welcome.
Metadata
Release files for dash-auth-external 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dash_auth_external-1.2.1.tar.gz | 8.3 kB | Without provenance | Details for dash_auth_external-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dash_auth_external-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for dash_auth_external-1.2.1-py3-none-any.whl |
Total release size: 18.8 kB
Release files / dash_auth_external-1.2.1.tar.gz
| Download URL | dash_auth_external-1.2.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd2bbf695e7e91400a96652a9b5aaf587070fff1ccd1b083d605d1fcfc6a2ea0
|
|
BLAKE2b-256 checksum How to use checksums |
c5a9800f2632675dc7b3160c60df065cba693a95f2b76ca4f387fd5969fa4c5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / dash_auth_external-1.2.1-py3-none-any.whl
| Download URL | dash_auth_external-1.2.1-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4661fa1f4d9c12c2fd91f3a014dbf85f6ed7d3079c96b1c7d15fece033c346fa
|
|
BLAKE2b-256 checksum How to use checksums |
02b0bc35c9ccbe95ea68b30482a09103f52d3da19cbf2c52e0d4d21e63bd197e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for dash-auth-external 1.2.1
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.