Skip to main content

Python utilities for Auth0

Project description

Test Coverage Status PyPI version

pyauth0

Python utilities for Auth0.

Usage

Verify a 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()},
))

Get a machine-to-machine token.

from pyauth0 import TokenVerifier, Auth0Error

token_verifier = TokenVerifier(
    issuer="your-domain.auth0.com",
    audience="https://your-domain.com/api",
    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-tenant.com/claim_name", "default value")

Contribute

If you want to contribute, open a GitHub Issue and motivate your request.

Project details


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.0.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pyauth0-0.0.5-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pyauth0-0.0.5.tar.gz.

File metadata

  • Download URL: pyauth0-0.0.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyauth0-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a0fedf67a119074ce2d863b93112eaa8cd8526c217b0adfb794f930109790d03
MD5 888da572e0a07b79244376c0bd424064
BLAKE2b-256 dfdd8ad36b082c40d3f818ec406534be075a738e34631be7f4edbaf520a536c0

See more details on using hashes here.

Provenance

File details

Details for the file pyauth0-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pyauth0-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyauth0-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 354aa4e7b634f7d67d49f1b1a7b82a170b083835fcfd49bdee165f5dfc620cf9
MD5 19c7e674fd901259cccaa06f328ee661
BLAKE2b-256 10fd45a6878332f9edc13fc0241c400a3ce22e0db5a76773edcfab7a5034740a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page