Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ppx-client

Python client for the Preference Profile Exchange (PPX) reference provider and any conformant implementation.

Install

pip install ppx-client

Requires Python 3.11+. Published version: 0.1.0a1 (PyPI).

Alpha, tracking a draft specification. Expect breaking changes. The version is 0.1.0a1 on PyPI and 0.1.0-alpha.1 on npm — the same release in each ecosystem's required format.

Quick start (sync)

from ppx_client import PpxClient, GrantRequestInput, consent_redirect_url

with PpxClient(base_url="https://api.provider.app") as ppx:
    req = ppx.request_grant(GrantRequestInput(
        client_id="my-app",
        subject_id="did:example:user-123",
        purposes=["recommendation"],
        allowed_domains=["fragrance"],
        allowed_namespaces=["fragrance"],
        allowed_operations=["read"],
        cross_domain_transfer="deny",
        writeback_policy="review_required",
        requested_duration_days=30,
    ))

    # Send the user here to review and approve
    consent_url = consent_redirect_url(
        "https://app.provider.app",
        req.grant_request_id,
        return_to="https://my-app.example/callback",
    )

    # After approval, exchange for a grant-scoped token
    tok = ppx.mint_token(req.grant_request_id)

    # Use it to read scoped claims
    profile = ppx.effective_profile(
        context={"climate": "hot_humid"},
        requested_namespaces=["fragrance"],
        token=tok.access_token,
    )

Async

import asyncio
from ppx_client import PpxAsyncClient, GrantRequestInput

async def main():
    async with PpxAsyncClient(base_url="https://api.provider.app") as ppx:
        card = await ppx.discovery_card()
        print(card.name, card.supported_namespaces)

asyncio.run(main())

Grant re-use

from ppx_client import PpxGrantRevokedError

try:
    fresh = ppx.refresh("my-app", cached_grant_id)
except PpxGrantRevokedError:
    # Clear cache, re-run the full approval flow
    cached_grant_id = None

AG-UI consent event streaming

from ppx_client import subscribe_ag_ui

for event in subscribe_ag_ui(f"https://api.provider.app/v1/ag-ui/consent/{req_id}"):
    print(event["type"], event)
    if event["type"] == "RUN_FINISHED":
        break

Async variant: subscribe_ag_ui_async.

License

Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppx_client-0.1.0a1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

ppx_client-0.1.0a1-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file ppx_client-0.1.0a1.tar.gz.

File metadata

  • Download URL: ppx_client-0.1.0a1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ppx_client-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 44d44ba44e6868d8adb2c78467429b2eb621befbc2e138ee250432cd42131a4e
MD5 123f9c2952198c83fa7254bd646cb2b6
BLAKE2b-256 ca74b67c88885c9f39c8f044abd7d7fcdd13e729fe21514e5f0f947eeb987b72

See more details on using hashes here.

File details

Details for the file ppx_client-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: ppx_client-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ppx_client-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 60c9dfbb94f7fec76917dadb3411db7e1d51a750609cf49054d1e32489723c16
MD5 a3bbc77ac680d0d7e4c3c259613aef5c
BLAKE2b-256 cc2402b3ab9a096ac18628dfb42e1328dd7a1728ec5d91e0f484d0fcbc09a9b4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 files

Supported by

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