Skip to main content

Python utilities for Auth0

Project description

pyauth0

Test Coverage Status PyPI version

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


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.3a0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

pyauth0-0.1.3a0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pyauth0-0.1.3a0.tar.gz.

File metadata

  • Download URL: pyauth0-0.1.3a0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for pyauth0-0.1.3a0.tar.gz
Algorithm Hash digest
SHA256 ddbbdfda4c70a658ee53293ceeefd2228d35b6cd7e609a1ed106da2020d5caed
MD5 306f68b27077b9145b9845e89fd2afd4
BLAKE2b-256 3301ea605e427d5b6cfec30d0af9ce2143cf334c4bc6231a618cd0e0431da615

See more details on using hashes here.

Provenance

File details

Details for the file pyauth0-0.1.3a0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pyauth0-0.1.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ce89ac1d60d9364a0582851e75f5dd3b5407668ab0ea7696c880ca05d30ef2
MD5 58ca99fc02dd0cc4918eaa92f020f639
BLAKE2b-256 64727c095bd554bf64d64f75400366a84ad92e1a4cf561710bbc0535bbe32fc0

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