Destinelab Python package
Project description
DestinE Auth
DestinE Auth is a helper package that simplifies authentication for DestinE workflows:
- Authenticate with DESP credentials.
- Get a DESP access token. (Normally transparent for the user)
- Exchange that token for a DEDL access token.
A Destination Earth - Data Lake access token is necessary to interact with Destination Earth - Data Lake APIs and services.
Install
pip install destinelab
Note: Python compatibility: 3.8+
Quick usage
- Here's a quick example of how to use the
AuthHandlerto get a DEDL token using DESP credentials. This is the recommended approach for most users, as it handles caching and token refresh automatically.
from destinelab import AuthHandler
handler = AuthHandler("DESP_USERNAME", "DESP_PASSWORD")
dedl_token = handler.get_token()
auth_headers = {"Authorization": f"Bearer {dedl_token}"} # Example of how to use the token in API requests
Logging and debug level
By default, the package is quiet and does not configure global logging. To enable debug output for troubleshooting, configure the package logger explicitly:
import logging
from destinelab import configure_logging
configure_logging(level=logging.DEBUG)
You can set INFO, WARNING, ERROR, or DEBUG depending on how much detail you need.
Service account usage (client credentials)
from destinelab import DEDLServiceAccountAuth
dedl_token = DEDLServiceAccountAuth(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
).get_token()
Check roles and DT access
AuthHandleralso provides helper methods to check the roles associated with the token and whether DT access is allowed, which can be useful for debugging or conditional logic in your application.
from destinelab import AuthHandler
handler = AuthHandler("DESP_USERNAME", "DESP_PASSWORD")
dedl_token = handler.get_token()
roles = handler.get_roles(dedl_token)
is_dt_access_allowed = handler.is_DTaccess_allowed(dedl_token)
DESP and DEDL token exchange (i.e. breaking the process down into individual steps)
- This is not recommended or useful for typical users, but can be useful for debugging or if you need more control over the individual steps.
from destinelab import DESPAuth, DEDLAuth
desp_token = DESPAuth("DESP_USERNAME", "DESP_PASSWORD").get_desp_token()
dedl_token = DEDLAuth(desp_token).get_token()
Error behavior
DESPAuth.get_desp_token()raises explicit auth errors (for example invalid credentials, OTP required, network failures, and DESP token exchange failures).DEDLAuth.get_token()raises explicit exceptions on exchange failure.DEDLServiceAccountAuth.get_token()raises explicit exceptions on service-account authentication failure.AuthHandler.get_token()first checks whether an already stored DEDL token is still valid (verified against DEDL Keycloak JWKS). If valid, it is returned immediately; otherwise it composesDESPAuth -> DEDLAuthusing DESP user credentials.- If cached-token validation cannot be completed because the validator backend is unavailable (for example metadata/JWKS lookup issues),
AuthHandler.get_token()logs a warning and continues with a refresh flow (DESPAuth -> DEDLAuth).
License
This project is licensed under MIT. See LICENSE.
MIT License
Copyright (c) 2025 Patryk Grzybowski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file destinelab-1.14.tar.gz.
File metadata
- Download URL: destinelab-1.14.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18c980dbb2d7c41f9d2ee6cf617f664998dd26d5a1a019ba6dda129f18787297
|
|
| MD5 |
fc3313ea7cdd87d2a10dd8a2650e8a96
|
|
| BLAKE2b-256 |
cbf0bc7b5bf8961ac49f1a9cb676460ce251d1a9d74dffcf91957225972cbb5a
|
File details
Details for the file destinelab-1.14-py3-none-any.whl.
File metadata
- Download URL: destinelab-1.14-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23cf550465bbe485050d7261f580cb8f01dbd1c33ab8141c6b1741a8fff08918
|
|
| MD5 |
977d2efa7220f2cf43d4771b111efe9b
|
|
| BLAKE2b-256 |
fdaaae45e59bba4bc2dd8ac4cd2f22c6d826eddd98f4b01e22c7e2ef154d7225
|