Skip to main content

Sparta Auth0 library

Project description

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

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

sparta-auth0-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparta_auth0-1.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file sparta-auth0-1.0.0.tar.gz.

File metadata

  • Download URL: sparta-auth0-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for sparta-auth0-1.0.0.tar.gz
Algorithm Hash digest
SHA256 962653703b1372b6965f8a81a321f10d7258bcd7556e0005fcae1c24cf3ab78c
MD5 4d8a38f960627a049a3581ef0ed1c068
BLAKE2b-256 f78274994d596146f02b358c416fcf749b068afcbf8952ee281e383db4102929

See more details on using hashes here.

File details

Details for the file sparta_auth0-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sparta_auth0-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for sparta_auth0-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9f702a47d9adb55e16a02f6aff86bbfaa7db78354a727918fbd8e1436d441fe
MD5 3bea743c86b59643faa414983672524f
BLAKE2b-256 7ff70c880911824fb43177a94651ae164c71b14fb51aad618e8bb07962d1a289

See more details on using hashes here.

Supported by

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