scitex_hub.account.whoami

Python parity for scitex-hub account whoami.

Same identity probe the CLI whoami verb hits — GET /api/me/ — so an agent-programmatic caller can confirm “is my cached token still valid?” without shelling out.

Functions

whoami(*[, server, request_fn])

Return the identity the cached bearer authenticates as.

scitex_hub.account.whoami.whoami(*, server: str | None = None, request_fn=None) → dict[source]

Return the identity the cached bearer authenticates as.

Parameters:
  • server – Override server URL. Defaults to _auth.resolve_server() (env / cache / scitex.ai).

  • request_fn – Dependency-injection seam for the HTTP GET. When None, uses requests.get. Tests inject a fake that returns the same {status_code, json, text} dict shape the real transport produces.

Returns:

Dict with exactly id (opaque UUID), username, is_staff, is_superuser, plan, key_id and expires_at (no email).

Raises:

RuntimeError – No bearer token resolved (not logged in), token expired (401), or server returned non-200.

Example

>>> from scitex_hub.account.whoami import whoami
>>> whoami()
{'id': '6f1c…', 'username': 'ywatanabe', 'is_staff': True, ...}
scitex_hub.account.whoami._default_get(url: str, headers: dict) → dict[source]

Default GET transport — wraps requests into the dict shape.