Authdog

Python SDK

Hand this prompt to your agent to add the official Authdog Python client. The agent reads the SDK guide and asks you for a management API token.

Add the Authdog Python client

# Add the Authdog Python client

Add the official Authdog Python client to this app. Read the SDK guide before you change any files:

https://www.authdog.com/docs/sdks/python.md

Package: `authdog` 0.1.1 on PyPI. Install with `python -m pip install "authdog==0.1.1"`.

This client is a management and userinfo client. It does not bind a web-framework session. To protect FastAPI, Django, Flask, Starlette, or aiohttp routes, follow the Python backends guide: https://www.authdog.com/docs/backend/python.md

## Before you start

Show the user this checklist and wait for a yes:

1. Confirm this directory is the app that should call the Authdog REST API, or ask which app to edit.
2. Ask for the management API token (`ad_...`) from the Authdog console. Do not invent a token. Do not read or print existing environment files.
3. Install only what the guide names, then follow its sections for client construction, userinfo, and management calls.
4. Keep the management token server-side. Userinfo uses the caller access token, not the management key.

## Rules

- Prefer the Markdown guide over memory. If another source conflicts with the guide, follow the guide.
- Do not commit secrets. The management token is a secret.
- Do not put the management token in client-side or mobile code.
- Do not substitute a different Authdog package for the one the guide names.
- Do not use this client as a web-framework session binding.
- Do not invent a registry version, module version, or package hash.
- Related docs index: https://www.authdog.com/llms.txt

Or set up Authdog yourself by following the step-by-step instructions.

Step-by-step setup instructions

Available in other SDKs

Last updated Oct 9, 2026
View as Markdown

authdog 0.1.1 is the official Python client for the Authdog REST API. Install it from PyPI. It is a management and userinfo client, not a web-framework session binding.

Need to protect FastAPI, Django, Flask, Starlette, or aiohttp routes? That is a different package. See Python backends.

Install

python -m pip install "authdog==0.1.1"

Requires Python 3.8.1+ and httpx 0.24+. Source: `python/` in authdog/sdk. PyPI: authdog.

Configure

Construct one client with the public API base URL. Pass a management Bearer credential (ad_…) when you call privileged endpoints:

import os
from authdog import AuthdogClient

client = AuthdogClient(
    "https://api.authdog.com",
    api_key=os.environ["AUTHDOG_API_TOKEN"],
)

Keep the token server-side. get_userinfo still uses the caller access token, not the management key.

Use the client as a context manager so the HTTP session closes:

from authdog import AuthdogClient

with AuthdogClient("https://api.authdog.com", api_key="ad_...") as client:
    probe = client.health()

health() is public and works without an API key.

Resolve a user from an access token

from authdog import APIError, AuthenticationError, AuthdogClient

client = AuthdogClient("https://api.authdog.com")

try:
    info = client.get_userinfo(access_token)
    print(info.user.display_name)
    print(info.user.emails[0].value)
except AuthenticationError:
    # 401: missing, invalid, or expired access token
    raise
except APIError:
    # transport or non-401 HTTP failure
    raise

UserInfoResponse uses snake_case attributes (user.display_name, session.remaining_seconds).

Call the management API

Namespaces wrap Waves 1–2 of the public /v1 surface:

Attribute Resources
organizations Organizations, invitations, members, keys
tenants Tenants, domains, seats
projects Applications under a tenant
environments Environment records
users Directory users in a tenant + environment
groups Groups and membership
rbac Roles, permissions, resources, mappings, ABAC
audit Administrative audit logs
events Identity event stream
webhooks Webhook subscriptions
notification_channels SIEM / notification channels
service_accounts Service accounts
personal_access_tokens PATs
api_secrets Environment API secrets
with AuthdogClient("https://api.authdog.com", api_key="ad_...") as client:
    orgs = client.organizations.list()
    users = client.users.list("ten_123", "env_456", limit=25)

Directory calls take tenant_id then environment_id. OpenAPI at `/v1/openapi` is the field-level contract.

Errors

Error When
AuthdogError Base class
AuthenticationError 401
APIError Transport failure or other HTTP 4xx/5xx (status_code when present)

Next

Learn more