Skip to main content

sparta-auth0

Sparta auth0 library.

Usage

from sparta.auth0 import AuthError, TokenVerifier

tv = TokenVerifier(
    auth0_domain="your-domain.auth0.com",
    api_audience="https://your-domain.com/api",
    jwks_cache_ttl=60,  # optional
)
try:
    token_payload = tv.verify_auth_header(
        "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...."
    )
except AuthError as error:
    status_code = error.status_code  # suggested status code (401 or 403)
    code = error.code  # auth0 error code (example "invalid_header")
    description = error.description  # auth0 error description (example "Unable to parse authentication token")
    raise

your_claim = token_payload.get_required_claim("https://your-domain.com/your_claim")
from sparta.auth0 import TokenProvider
from urllib.request import Request, urlopen

tp = TokenProvider(
    issuer="your-domain.auth0.com",
    audience="https://your-domain.com/api",
    client_id="1234",
    client_secret="secret"
)

# Machine to machine request
response = urlopen(Request(
    "https://other-machine.your-domain.com/api",
    headers={"authorization": tp.get_token().get_authorization()},
))

Release files for sparta-auth0 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sparta-auth0 1.0.0
File Size Uploaded
sparta-auth0-1.0.0.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sparta-auth0 1.0.0
File Interpreter ABI Platform
sparta_auth0-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / sparta-auth0-1.0.0.tar.gz

Download URL sparta-auth0-1.0.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
962653703b1372b6965f8a81a321f10d7258bcd7556e0005fcae1c24cf3ab78c
BLAKE2b-256 checksum
How to use checksums
f78274994d596146f02b358c416fcf749b068afcbf8952ee281e383db4102929
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / sparta_auth0-1.0.0-py3-none-any.whl

Download URL sparta_auth0-1.0.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9f702a47d9adb55e16a02f6aff86bbfaa7db78354a727918fbd8e1436d441fe
BLAKE2b-256 checksum
How to use checksums
7ff70c880911824fb43177a94651ae164c71b14fb51aad618e8bb07962d1a289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page