Skip to content

Auth

polestar_api.auth

Async OIDC/PKCE authentication for the Polestar API.

TokenStore

Bases: Protocol

Protocol for pluggable token persistence.

FileTokenStore

FileTokenStore(path: str | Path)

Stores tokens in a JSON file.

MemoryTokenStore

MemoryTokenStore()

In-memory token store (no persistence).

AuthManager

AuthManager(token_store: TokenStore | None = None)

Manages OIDC authentication and token lifecycle.

authenticate async

authenticate(email: str, password: str) -> None

Full OIDC/PKCE auth flow. Tries token refresh first if available.

ensure_valid_token async

ensure_valid_token() -> str

Return a valid access token, refreshing or re-authenticating if needed.