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.3a1.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file pyauth0-0.1.3a1.tar.gz
.
File metadata
- Download URL: pyauth0-0.1.3a1.tar.gz
- Upload date:
- Size: 4.6 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 | 4c650d6633fc0ae1dd0c39a4e721894a46e2f2ef6f33cdf68696d821da2ef71c |
|
MD5 | 78217c4de6a35f38ddba76adacbc7ce9 |
|
BLAKE2b-256 | e505af69712866a86bd19d367eb25f87eb41517f37d989d54875394fb7a8365f |
Provenance
File details
Details for the file pyauth0-0.1.3a1-py3-none-any.whl
.
File metadata
- Download URL: pyauth0-0.1.3a1-py3-none-any.whl
- Upload date:
- Size: 5.9 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 | 68fbb6103f0023a95b74849bc95bf2cdbc14c80c6f2e18bd0139ca5f2071c40f |
|
MD5 | 1c8229c525d8f5b54ad2cac99ff9c29f |
|
BLAKE2b-256 | 644b3956d297cd5fc3f7cb48bf320fb0749f5dc428407340801c525264d0ad2e |