Skip to main content

Official Python SDK for Huudis — email/social/MFA, fine-grained authorization, webhook signature verification, and full admin API (IAM, workspaces, end-users, billing, webhook subscriptions) with OIDC device-flow auth and multi-profile session store.

Project description

huudis (Python)

Official Python SDK for Huudis. Works with FastAPI, Flask, Django, or anything else that speaks WSGI/ASGI.

Install

pip install huudis

Quickstart

Set env vars (or pass them to the client):

HUUDIS_ISSUER=https://huudis.com
HUUDIS_AUDIENCE=oc_your_client_id
HUUDIS_CLIENT_ID=oc_your_client_id
HUUDIS_CLIENT_SECRET=cs_...   # omit for public clients (PKCE)

Verify an access token

from fastapi import FastAPI, Header, HTTPException
from huudis import verify_access_token, HuudisAuthError

app = FastAPI()

@app.get("/me")
def me(authorization: str = Header(...)):
    try:
        claims = verify_access_token(authorization)
    except HuudisAuthError as e:
        raise HTTPException(401, detail=e.message)
    return {"user_id": claims.sub, "email": claims.email}

OIDC sign-in flow

from huudis import HuudisClient

huudis = HuudisClient()

# Step 1: redirect the user
url = huudis.authorization_url(
    redirect_uri="https://yourapp.com/callback",
    state=session["state"],
    code_challenge=session["pkce_challenge"],
)

# Step 2: exchange the code
tokens = huudis.exchange_code(
    code=request.args["code"],
    redirect_uri="https://yourapp.com/callback",
    code_verifier=session["pkce_verifier"],
)
userinfo = huudis.userinfo(tokens["access_token"])

Authorization check

result = huudis.authz_check(
    access_token=token,
    principal={"type": "user", "id": claims.sub, "accountId": claims.account_id},
    action="plugipay:DeleteInvoice",
    resource="forjio:plugipay::acc_.../invoice/inv_9F8",
)
if not result["allow"]:
    raise HTTPException(403, detail=result.get("reason"))

Types

Name Description
verify_access_token(header_or_token, *, issuer=None, audience=None, require_mfa=False) Module-level convenience — reads HUUDIS_ISSUER / HUUDIS_AUDIENCE from env.
HuudisClient(issuer=..., client_id=..., client_secret=..., audience=..., api_base=...) Full surface. Use as a context manager (with HuudisClient() as huudis:) or call .close().
HuudisClaims Dataclass returned by verification — sub, email, account_id, scope, mfa_verified, etc.
HuudisAuthError Raised on any failure; carries .code + .message.

JWKS is cached in-process via PyJWT's PyJWKClient.

Docs

License

MIT

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

huudis-0.4.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

huudis-0.4.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file huudis-0.4.0.tar.gz.

File metadata

  • Download URL: huudis-0.4.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for huudis-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6ca25b0b5b1b0e7738e150593ddf5152de10e250bdd34838e606c46053b927d5
MD5 5b589c34c4ea6b5d7862f674793c8834
BLAKE2b-256 f68551deb9f5e00d4b44d6b9253c31dbfd88b8620f0c39a8b0a577ff0b842c98

See more details on using hashes here.

File details

Details for the file huudis-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: huudis-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for huudis-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 294eb5d839d18c1222538df936bcca9c77a3c300481388a52e2d2b5f41b0b5cf
MD5 38288ba4b5f06988f8e1045a32f7cc97
BLAKE2b-256 9cf9b44ea4a3311c34ca6e39dfc6bb0c403423eb02af466d930eea0bb2f8d153

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