Python SDK
The OhAuthCat server SDK for Python: typed sync and async clients, SSO helpers and webhook verification.
Typed sync (OhAuthCat) and async (AsyncOhAuthCat) clients.
Install
Section titled “Install”pip install ohauthcatConfigure
Section titled “Configure”OhAuthCat( creates the client; for sign-in also pass client_id="pk_..." and environment_id="env_.. Optional: timeout_ms, max_retries, and api_base_url / auth_base_url for any deployment other than production. Use it as a context manager (with OhAuthCat() so its HTTP client is closed.
First call
Section titled “First call”Every API operation is a method on its resource: client., or client.. client.events.list() iterates forwards over every event. On AsyncOhAuthCat, await the same methods.
SSO: client. returns .url and .code_verifier; store both in your server session. On the callback, compare the state, then call client. once. The Python quickstart shows the complete flow with state, session binding and replay checks.
Errors
Section titled “Errors”Every API error is an OhAuthCatError with the stable code, status, type, param, doc_url and request_id; see the error codes. PlanLimitReachedError adds the metric a plan refused. RestartSignIn means the code exchange cannot be retried: start a fresh sign-in.
Webhooks
Section titled “Webhooks”webhooks. (from ohauthcat import webhooks) checks the OhAuthCat-Signature header against the exact raw body bytes and returns the event. Pass every secret you hold during a rotation. A refusal raises ohauthcat. whose code is, for example, signature_invalid or timestamp_outside.
Reference
Section titled “Reference”Every method maps to an operation in the API reference; webhook payloads are in webhook events.