gooclaim-aiveth-sdk is the Aiveth by Gooclaim SDK for Python servers. Use it to check ID tokens, access tokens, machine tokens and AI agent tokens, to verify webhooks, and to call the admin API. It is synchronous and uses httpx.
Install
Requires Python 3.10 or later.gooclaim_aiveth_sdk.
Configure
Aiveth is a context manager. Call close(), or use with, to close its HTTP client:
aiveth_sk_test_... for Development and aiveth_sk_live_... for production.
Tokens
All token methods return the claims as adict.
tokens.verify_id_token(token, *, client_id)
Checks an app’s ID token offline against Aiveth’s published keys: signed by Aiveth, for this app, and not expired.
tokens.user_from_access_token(access_token)
An app’s access token is opaque. Aiveth says who it stands for. Returns None when the token has ended.
tokens.verify_machine_token(token, *, org_id)
Checks a machine app’s token meant for your organization’s services.
tokens.verify_mcp_token(token, *, resource, scopes=())
Checks an AI agent’s token for your MCP server. resource is the server’s address as registered in Aiveth. A token for any other server is refused. Missing scopes raise InsufficientScopeError.
tokens.connected_token(*, access_token, connection, client_id, client_secret)
Gets the Google, Microsoft or GitHub token a person connected for your organization’s apps. Returns {access_token, expires_in?, scope}. Server only: it needs your app’s secret, and the app must have Connected accounts turned on.
tokens.discover()
Returns Aiveth’s OpenID Connect discovery document. The other token methods call it for you.
has_flag(claims, key)
Is a feature flag on for this person? Aiveth puts the flags that are on for the person in the ID token as feature_flags.
Webhooks
verify_webhook(raw_body, headers, secret, *, tolerance_seconds=300, now=None)
Checks that Aiveth signed exactly these bytes, recently, and returns the parsed message. Raises WebhookVerificationError otherwise. secret is the whsec_... secret the console showed once. Pass the raw request body.
webhook-ids you have handled and skip repeats. See Webhooks.
Admin API
These need an API key with the right power. Every refusal raisesAivethError with Aiveth’s message and status. The powers are the same as in the Node SDK.
People
Invitations, roles and organization fields
Fine-grained permissions
See Fine-grained authorization.Consent
See Consent.allows each time rather than storing the answer.
Events
events.list(*, types=None, after=None, limit=None, range_start=None)
Reads your organization’s events, oldest first. Page on with list_metadata["after"]. Needs events:read.
Protect an MCP server
Register your MCP server in the console under AI agents, then:metadata_url(resource) gives the address where the metadata document lives. An agent token is for one MCP server. It lasts 10 minutes, and the agent renews it. See MCP servers.
Errors
All of them are subclasses of
AivethError.