Python SDK for the Partner Ecosystem: JWKS-based auth verification and server-to-server actions.
Project description
ab-ecosystem-python
Python SDK for the Partner Ecosystem: JWKS-based auth verification and
server-to-server actions. It mirrors the [ab-ecosystem-node] package.
Install
pip install ab-ecosystem-python
Quick start
Initialise once at start-up, then call the user methods anywhere — either via
the module-level helpers (they use the process-wide singleton) or on the client
returned by init.
from ab_ecosystem import init, get_user_profile, get_user_subscription
init(
api_url="https://api.example.com",
project_id="proj_123",
project_secret="super-secret",
)
# module-level (singleton)
profile = get_user_profile(access_token=user_jwt)
# or on the instance
client = init(api_url="...", project_id="...", project_secret="...")
subscription = client.get_user_subscription(access_token=user_jwt)
Methods
| Method | Endpoint |
|---|---|
get_user_profile() |
GET /api/v1/projects/:project_id/me |
get_user_wallet() |
GET /api/v1/projects/:project_id/me |
get_user_credit_wallet() |
GET /api/v1/projects/:project_id/credit-wallets |
get_user_subscription() |
GET /api/v1/projects/:project_id/subscription |
ping() |
GET /ping |
:project_id is filled from your config. Each user method takes an optional
access_token (the end-user's JWT), forwarded as Authorization: Bearer <token>
so the API can resolve the call as that user. Every call also sends the project
credentials via HTTP Basic auth plus the x-project-id header.
Verifying incoming tokens
The Node SDK ships an Express middleware; in Python the framework-agnostic core is exposed instead, so you can wire it into Flask, FastAPI, Django, etc.
from ab_ecosystem import verify_token, extract_bearer_token
token = extract_bearer_token(request.headers.get("authorization"))
claims = verify_token(token) # raises jwt.PyJWTError on failure
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ab_ecosystem_python-0.1.1.tar.gz.
File metadata
- Download URL: ab_ecosystem_python-0.1.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7083cb47dc6551569e281513fac9fa8f257c3e11fec3ccc1ca3378f3a1a6851
|
|
| MD5 |
e57847519f4e3e515762f497065569d3
|
|
| BLAKE2b-256 |
21062c33721a0fc057c451b22f27c25c7fbc26d70494897f9bcfc9e823b1b4a0
|
File details
Details for the file ab_ecosystem_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ab_ecosystem_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
257a9fd529e1d2ff299b655ef224be22c4d0f37b7c77a90f931581249376c9e0
|
|
| MD5 |
092ee58cd5ee8319f172541abfdd838a
|
|
| BLAKE2b-256 |
ea6de5c296ab2b0364aa02b69daa86dd08675e05b3c3bba5f83000018316ef71
|