Python SDK
idenplane is the official server-side Python SDK for Idenplane. It wraps OIDC discovery and admin management (users, roles, groups) against the Idenplane realm-management API with a fully-typed, mypy --strict-clean client.
Requirements
| Requirement | Version |
|---|---|
| Python | 3.9+ |
The only runtime dependency is requests.
Installation
pip install idenplane
Quick start
from idenplane import Client, Config
# Or: Config.from_env() — reads IDENPLANE_BASE_URL, IDENPLANE_REALM,
# IDENPLANE_ADMIN_TOKEN.
cfg = Config(
base_url="https://auth.example.com",
realm="my-realm",
admin_token="eyJ...", # service-account token with realm-management role
)
with Client(cfg) as client:
# OIDC discovery (cached for 5 minutes by default)
oidc = client.discovery.get()
print(oidc["token_endpoint"])
# Create a user
user = client.users.create({
"username": "alice",
"email": "alice@example.com",
"firstName": "Alice",
"enabled": True,
})
print(user["id"])
The Client owns a single requests.Session, reused across calls for connection pooling. Use it as a context manager (as above) so the session is closed automatically, or call client.close() yourself.
User management
from idenplane import Client, Config, ListUsersOptions
with Client(Config.from_env()) as client:
# Read
user = client.users.get("user-id-123")
# List with filters and pagination (page is 1-based, limit defaults to 20)
result = client.users.list(
ListUsersOptions(page=1, limit=25, search="alice", enabled=True)
)
print(result["total"], "users")
for u in result["users"]:
print(u["username"])
# Update
user = client.users.update("user-id-123", {"email": "new@example.com"})
# Reset password
client.users.reset_password("user-id-123", "S3cret!", temporary=True)
# Delete
client.users.delete("user-id-123")
Role management
Realm roles are addressed by name, not by ID, and the endpoint returns the full record synchronously on create/update — no follow-up fetch needed:
with Client(Config.from_env()) as client:
role = client.roles.create({"name": "billing-admin", "description": "Can manage billing settings"})
role = client.roles.get("billing-admin")
roles = client.roles.list()
role = client.roles.update("billing-admin", {"description": "Updated description"})
client.roles.delete("billing-admin")
Group management
Groups are addressed by ID and support nesting via parentId:
with Client(Config.from_env()) as client:
parent = client.groups.create({"name": "engineering"})
child = client.groups.create({"name": "platform-team", "parentId": parent["id"]})
group = client.groups.get(child["id"])
groups = client.groups.list()
group = client.groups.update(child["id"], {"name": "platform-infra"})
client.groups.delete(child["id"])
Errors
All SDK errors inherit from idenplane.IdenplaneError. HTTP responses are
mapped to typed subclasses so callers can catch what they care about:
| Status | Exception |
|---|---|
| 401/403 | AuthError |
| 404 | NotFoundError |
| 429 | RateLimitError |
| 5xx | ServerError |
| other | IdenplaneError |
from idenplane import Client, Config
from idenplane.exceptions import NotFoundError
with Client(Config.from_env()) as client:
try:
client.users.get("does-not-exist")
except NotFoundError as exc:
print("not found:", exc.status_code, exc.body)
Discovery cache
DiscoveryCache is thread-safe and TTL-bounded (default 5 minutes). It is
exposed via client.discovery.cache for tests and advanced use:
with Client(cfg) as client:
client.discovery.get() # network call
client.discovery.get() # cache hit
client.discovery.invalidate() # clear all realms
client.discovery.refresh() # forced refetch
Next Steps
Go SDK Server-side Go SDK for the same admin API
CLI Manage the same resources from the terminal
API Reference Complete REST API documentation
Configuration Learn about all configuration options