Skip to main content
The theauth package is the Python client for the theAuth REST API. It is built on httpx and ships a sync client and an async client with the same surface. Python 3.9 or newer.

Installation

Create a client

Resources

MCP servers

Plugin routes

Call routes declared with defineEndpoint through request(). It returns the parsed JSON body.
Validation failures raise ValidationError with the server issues. A 403 CSRF_REJECTED raises PermissionError, and a 429 raises RateLimitError with retry_after.

DPoP

DPoPAuth signs each request with an ES256 key pair, as described in RFC 9449.
  • The Authorization header becomes DPoP <token> and the proof carries an ath claim.
  • htu drops the query and fragment.
  • The server DPoP-Nonce is cached per origin and a use_dpop_nonce response is retried once.
DPoPAuth is a plain httpx.Auth, so you can also pass it to your own httpx.Client or httpx.AsyncClient. The cryptography package is imported lazily and a clear error is raised if it is missing.

Devices

client.devices is the registry and needs a user or admin token. client.device is what a device calls as itself: enroll, authorize, fetch an offline policy bundle.
DeviceAssertionSigner signs the device-assertion+jwt the server verifies. It makes a new assertion for every call because the server accepts each jti once. It needs the cryptography extra, like DPoP.

Step-up

A 401 with error="insufficient_user_authentication" (RFC 9470) raises StepUpRequiredError, a subclass of AuthenticationError. error.challenge.authorize_params() gives the acr_values and max_age for the new authorization request.
acr_satisfies and auth_is_fresh check a token’s acr and auth_time before you call.

Bound tokens and input provenance

Pass cnf=dpop_confirmation(prover) to CreateAgentInput to bind an agent token to a DPoP key (RFC 7800). client.agents.rotate(id) keeps the binding, rotate(id, cnf=None) removes it. AuthorizeRequest(inputs=[ProvenanceInput("user_message", content=text)]) records what the model had in context; the server hashes the content and does not store it.

Errors

All exceptions inherit from TheAuthError and carry code, message and status_code.

Client SDK

The TypeScript fetch client this package mirrors.

Expo

React Native and Expo integration.
Last modified on October 19, 2026