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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyauth0-0.0.6.tar.gz
Algorithm Hash digest
SHA256 40ab063278235441c30da067725716cdd01b321844b35ef498555a6d1b5e5e86
MD5 ce7b92825f8c5c250c76a4910ba5a16d
BLAKE2b-256 143ba64e40660f7c2b9f8c5d878ac4f9024a7b9535927f50293848c570acb2b7

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyauth0-0.0.6-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.11.6

File hashes

Hashes for pyauth0-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b4c806cdac6f5a735151928095acaf66ada10aa25f4bd1106e0c86b1ba533ad7
MD5 9adf54d520b20621281eeefd013704f7
BLAKE2b-256 352ff8b0d5d4de825bf02865f875cd6a8fd76de89c7fa314bf704db7c1abaa60

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