Skip to main content

aiveth

Aiveth for Python (3.10 or later).

from aiveth import Aiveth, verify_webhook

aiveth = Aiveth("https://aiveth.example.com", api_key=os.environ["AIVETH_API_KEY"])

claims = aiveth.tokens.verify_id_token(id_token, client_id="your-app-client-id")
user = aiveth.tokens.user_from_access_token(access_token)  # None once it has ended
machine = aiveth.tokens.verify_machine_token(token, org_id="your-organization-id")

event = verify_webhook(request.body, request.headers, os.environ["AIVETH_WEBHOOK_SECRET"])

people = aiveth.people.list()
aiveth.invitations.send("new.person@example.com")
report = aiveth.people.import_all(people_from_your_old_system)  # each with external_id
# report["people"]: every person's Aiveth id next to your old id, to link your records
asha = aiveth.people.find_by_external_id("user_2abc")

Every refusal is a AivethError with Aiveth's own words and status.

A webhook may arrive twice within its 5 minutes: keep the webhook-ids you've handled and skip repeats.

Workspaces (your own customers inside your app)

made = aiveth.workspaces.create("Acme", external_id="org_123", creator_id=user_id)
aiveth.workspaces.invite(made["workspace"]["id"], "teammate@acme.com", role="member")

Check a token in your own API

Register your API in the console (Developers → Your APIs). Apps that ask for it get a signed access token; your API checks it here, with no call to Aiveth:

who = aiveth.tokens.verify_access_token(bearer, audience="https://api.acme.com", permissions=("invoices:read",))
# who["sub"], who["org_id"], who["role"], who["permissions"]

Protect an MCP server (AI agents)

Register your MCP server in the console (AI agents → MCP servers) with its address and permissions. Then, in your server:

from aiveth import Aiveth, InsufficientScopeError, TokenVerificationError, challenge, protected_resource_metadata

MCP = "https://mcp.acme.com/mcp"
aiveth = Aiveth(base_url="https://accounts.aiveth.com")

# GET /.well-known/oauth-protected-resource/mcp
metadata = protected_resource_metadata(resource=MCP, base_url="https://accounts.aiveth.com", scopes=["files:read"])

# every MCP request
try:
    who = aiveth.tokens.verify_mcp_token(bearer, resource=MCP, scopes=("files:read",))
except InsufficientScopeError:
    status, header = 403, challenge(resource=MCP, scope=["files:read"], error="insufficient_scope")
except TokenVerificationError:
    status, header = 401, challenge(resource=MCP, scope=["files:read"])

A token is for ONE MCP server (its aud); it lasts 10 minutes and the agent renews it.

Feature flags and the person's photo

from aiveth import has_flag
user = aiveth.tokens.verify_id_token(id_token, client_id=CLIENT_ID)
if has_flag(user, "new-billing"):
    ...  # show the new billing page
user.get("picture")  # their photo's address on Aiveth (with the `profile` scope)

A person's Google, Microsoft or GitHub token (connected accounts)

Turn on "Connected accounts" for the app in Aiveth, and let the person connect the account (Account → Connected for apps). Then, on your server:

google = aiveth.tokens.connected_token(access_token=access_token, connection="google",
                                        client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
google["access_token"]  # call Google as the person

Roles on parts of your organization (fine-grained permissions)

Make the types of part (like region → branch) and the roles for them in the console (Parts & access). Then your server registers each part as it makes it, gives roles on parts, and asks:

aiveth.authorization.register(type="branch", external_id="mumbai", name="Mumbai",
                               parent_type="region", parent_external_id="west")
aiveth.authorization.give("branch", "mumbai", "branch_approver", person_id=ravi)
answer = aiveth.authorization.check(ravi, "claim:approve", "branch", "mumbai")
answer["allowed"], answer["via"]

A role on a part covers everything under it. The key needs authorization:read for the check, resources:write to register parts and authorization:write to give roles.

Publish your consent notice in the console (Privacy). If your app asks on its own screen instead of Aiveth's, record the answers, check before you use the data, and let people withdraw:

aiveth.consents.record(person_id, notice_version, {"service": True, "news": False})
if aiveth.consents.allows(person_id, "news"):
    send_newsletter()
aiveth.consents.withdraw(person_id, "news")
receipt = aiveth.consents.receipt(person_id)["receipt"]  # signed, checkable with your JWKS
aiveth.consents.import_all(notice_version, earlier_consents)  # given before Aiveth

A yes with a time limit stops counting on its day, so always ask allows rather than keeping the answer. The key needs consent:read to check and consent:write to record.

Development and production

Each environment has its own keys: aiveth_sk_test_… and apps okc_test_… for your Development environment, aiveth_sk_live_… and okc_live_… for production.

A machine app's token, data to erase, AI agent actions (0.2.0)

token = aiveth.tokens.machine_token(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, scope="reports:read")
for task in aiveth.erasures.list():
    ...  # erase it in your app
    aiveth.erasures.done(task["id"])
aiveth.agent_actions.report(token=agent_token, action="claims.approve", idempotency_key=request_id)

Metadata

Release files for aiveth 0.11.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 aiveth 0.11.0
File Size Uploaded Provenance Actions
aiveth-0.11.0.tar.gz 26.0 kB Without provenance Details for aiveth-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiveth 0.11.0
File Interpreter ABI Platform Actions
aiveth-0.11.0-py3-none-any.whl Python 3 none any Details for aiveth-0.11.0-py3-none-any.whl

Total release size: 49.0 kB

Release files / aiveth-0.11.0.tar.gz

Download URL aiveth-0.11.0.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2cb3fd841b50ec786f773aa814070478dbdba0df4259067d6caf1507ee475344
BLAKE2b-256 checksum
How to use checksums
0ba49758e202c6378b03705b12b09ba1f07cd4e4bdf83563788f1d9b2c1fa471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / aiveth-0.11.0-py3-none-any.whl

Download URL aiveth-0.11.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a40d5f375ea93e84c473131c1f2d88254d586612f21837cdbed668fa0b4ce687
BLAKE2b-256 checksum
How to use checksums
6d585f5aee61a4fca5328840965f6c25946eeef7049ffc68f97ed583b7be4fe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for aiveth 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files No provenance

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