Python admin SDK for the Auth Platform Management API
Project description
lars-kluijtmans-admin-sdk
A Python admin SDK for the Auth Platform Management API — modelled on the Firebase Authentication Admin SDK. From a server-side program: read projects, clients and providers, and read/update users (active state, custom claims, password-reset/verification emails).
pip install lars-kluijtmans-admin-sdk
The import package stays auth_platform_admin (from auth_platform_admin import AdminClient).
Requires Python 3.10+.
Authenticating
Two credential modes.
M2M (recommended for servers)
A service client with the client_credentials grant. The SDK runs the grant against the
Login API, then caches and refreshes the token for you:
from auth_platform_admin import AdminClient
client = AdminClient.from_client_credentials(
login_api_url="https://login.example.com",
management_url="https://manage.example.com",
client_id="client_xxx",
client_secret="…",
)
Bring-your-own token
Attach an admin access token you already hold (e.g. from a logged-in session):
client = AdminClient(management_url="https://manage.example.com", token=ACCESS_TOKEN)
What a credential may do is governed by RBAC: a user token uses that user's role; a service client uses the role assigned to it (see Setting up a service client below).
AdminClient is a context manager and closes its HTTP connection on exit:
with AdminClient.from_client_credentials(...) as client:
...
Using it
# Projects
project = client.projects.get(project_id)
projects = client.projects.list(company_id)
# Clients & providers
clients = client.clients.list(project_id)
provider = client.providers.catalog() # platform catalog
enabled = client.providers.list(project_id) # per-project, with enable state
# Users — read
users = client.users.list(project_id, search="ann", status="active") # one page
for user in client.users.iter(project_id): # all pages
print(user.email, user.is_active)
user = client.users.get(project_id, user_id)
# Users — update (active state, claims, and profile fields)
client.users.set_active(project_id, user_id, False)
client.users.set_claims(project_id, user_id, {"tier": "gold"})
client.users.set_profile(project_id, user_id, {"display_name": "Ann", "language": "nl"})
# Firebase-style: apply whichever fields you pass (profile fields accept None to clear).
client.users.update(project_id, user_id, active=True, claims={"tier": "silver"},
display_name="Ann", language="nl", profile_picture="https://cdn/x.png")
# Users — remediation
client.users.send_password_reset(project_id, user_id)
client.users.resend_verification(project_id, user_id)
client.users.force_logout(project_id, user_id)
Every model exposes .raw (the full API payload) so new/unknown fields are always reachable.
The admin can edit display name, language, and profile picture (
set_profile/update), flip active state, set claims, and trigger the reset/verification emails. Email and password changes remain self-service on the Login API — they are not part of the admin surface.
Setting up a service client
- Create a client for the project (Management console → project → Clients, or the API) and
enable the
client_credentialsgrant on it. Keep theclient_id+ secret. - Assign it a role — the permissions an m2m token from this client gets:
PUT /api/v1/projects/{project_id}/clients/{client_id}/service-role { "role_id": "<a management role id>" }
(Needsrole:manage.) A client with no service role can mint a token but is denied everything. - Use
AdminClient.from_client_credentials(...)with that client's id + secret.
The service account is always scoped to its own company/project and is never a platform admin.
Errors
Failures raise typed exceptions — AuthError (401), Forbidden (403), NotFound (404),
Conflict (409), ValidationError (422), NetworkError — all subclasses of AdminError
(carrying .status and .detail):
from auth_platform_admin import NotFound, Forbidden
try:
client.users.get(project_id, user_id)
except NotFound:
...
except Forbidden as exc:
print(exc.status, exc.detail)
See examples/ for runnable scripts (M2M and bring-your-own-token).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lars_kluijtmans_admin_sdk-0.0.3.tar.gz.
File metadata
- Download URL: lars_kluijtmans_admin_sdk-0.0.3.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49bc7da51ad0164d5ff5979bac6ba685f7862772102eda5d4b460c95ea44a732
|
|
| MD5 |
81c42e5b2a33853c6013126e2a994a24
|
|
| BLAKE2b-256 |
0cb9db26347593142be93b2e712b74b68ed2e9bc2231ac1320e1e5af781e643b
|
File details
Details for the file lars_kluijtmans_admin_sdk-0.0.3-py3-none-any.whl.
File metadata
- Download URL: lars_kluijtmans_admin_sdk-0.0.3-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b730eb1cd9b3f75280a95099806576b9b74a14617389340a6b7498d77a0527
|
|
| MD5 |
49a2267c383b28b311dcff02f9f96dcf
|
|
| BLAKE2b-256 |
833c1475ca34ec40521c989765ea00bd7fc5628609ab04faa39c5340aba6fdb8
|