:::note Generated reference Generated from honeyframeapi 0.1.8 — do not edit by hand. :::
honeyframeapi.auth
Authentication strategies for the Honeyframe SDK.
Two strategies ship today, both injected into HoneyframeClient:
LoginAuth— email/password. Exchanges credentials for a short-lived (8h) JWT viaPOST /api/auth/loginand transparently re-logs-in when the token is rejected with a 401. Meant for interactive use; read the password withgetpass.getpass, never hard-code it.TokenAuth— a pre-minted bearer token: anhf_…Personal Access Token (recommended for scripts and jobs) or a JWT you already have. No auto-refresh: a 401 surfaces to the caller.
The client calls AuthBase.token before every request to obtain the
current bearer string, and AuthBase.refresh once on a 401 before
retrying. An auth strategy that cannot refresh returns False so the client
stops retrying and raises.
class AuthBase
Interface every auth strategy implements.
AuthBase.token()
token(http: httpx.Client) -> str
Return the current bearer token, acquiring one if needed.
AuthBase.refresh()
refresh(http: httpx.Client) -> bool
Force-acquire a new token after a 401.
Returns True if a fresh token was obtained (caller should retry),
False if this strategy cannot refresh (caller should raise).
class TokenAuth
TokenAuth(token: str)
Bases: AuthBase
Authenticate with a token you already hold (an hf_… PAT or a JWT).
TokenAuth.token()
token(http: httpx.Client) -> str
class LoginAuth
LoginAuth(username: str, password: str, *, login_path: str = '/api/auth/login')
Bases: AuthBase
Authenticate with email + password, caching the JWT and re-logging-in on 401.
LoginAuth.token()
token(http: httpx.Client) -> str
LoginAuth.refresh()
refresh(http: httpx.Client) -> bool
Functions
auth_from_kwargs()
auth_from_kwargs(*, token: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, auth: Optional[AuthBase] = None) -> AuthBase
Resolve the auth strategy from the assorted client kwargs.
Precedence: explicit auth object > token > username/password
> environment variables (HONEYFRAME_TOKEN then
HONEYFRAME_USERNAME/HONEYFRAME_PASSWORD). The legacy
HUB_USERNAME/HUB_PASSWORD fallbacks still work but emit a
DeprecationWarning.
Verified against honeyframeapi 0.1.8.