Python utilities for Auth0
Project description
pyauth0
Python utilities for Auth0.
Install
pip install pyauth0
Usage
Get a machine-to-machine token
from pyauth0 import TokenProvider
from urllib.request import Request, urlopen
token_provider = TokenProvider(
issuer="your-domain.auth0.com",
audience="https://api.your-domain.com",
client_id="1234",
client_secret="secret"
)
# Machine to machine request
response = urlopen(Request(
"https://api.your-domain.com",
headers={"authorization": token_provider.get_token().get_authorization()},
))
Verify a token
from pyauth0 import TokenVerifier, Auth0Error
token_verifier = TokenVerifier(
issuer="your-domain.auth0.com",
audience="https://api.your-domain.com",
jwks_cache_ttl=60, # optional
)
try:
decoded_token = token_verifier.verify(
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...."
)
except Auth0Error as error:
status_code = error.status_code # suggested status code (401 or 403)
code = error.code # pyauth0 error code (example "token_expired")
description = error.description # pyauth0 error description (example "Token is expired.")
raise error
claim_value = decoded_token.payload.get("http://your-domain.com/claim_name", "default value")
Contribute
If you want to contribute, open a GitHub Issue and motivate your request.
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
pyauth0-0.1.3a2.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file pyauth0-0.1.3a2.tar.gz
.
File metadata
- Download URL: pyauth0-0.1.3a2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ffd71d7b234238f2e5b96c30b0d42c07c60caf6e7bcd76376191b4f2fb29216 |
|
MD5 | f5bcb91271e56b0b6e9b08f5c42163bd |
|
BLAKE2b-256 | f9b28bdf82185c887bd561953d1ba3ab3f9e4595bbcb9f60fc363b990a6e2c38 |
Provenance
File details
Details for the file pyauth0-0.1.3a2-py3-none-any.whl
.
File metadata
- Download URL: pyauth0-0.1.3a2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf26c8c27b8c8709b443044fa7ed2312ffe351abaa8a7bf3b36b5df31192a3f2 |
|
MD5 | b3d90b581852fbc06c6151c57512805b |
|
BLAKE2b-256 | 9b85afa31f28b0d9994209efa44bb9acbc3f0872b2fea0adddbf0db7a79ac911 |