API referenceovok_sdk.resources

ovok_sdk.resources.session

The `ovok.session` namespace: the current user session and the accounts saved on this client.

  • Stable unknown
  • Release candidate not available
  • Development since 0.2.0-dev.34+53a6a64

The ovok.session namespace: the current user session and the accounts saved on this client.

SavedAccountsResource

SavedAccountsResource(http: HttpClient, session: UserSession | None)

The accounts signed in to on this client; access it as ovok.session.saved_accounts.

Every sign-in saves its account under ovok:<tenant_code>:saved-accounts in storage.

Parameters

NameTypeDefaultDescription
httpHttpClientThe client's HTTP client.
sessionUserSession | NoneThe user session; None for a machine client.

list()

list() -> list[SavedAccount]

List the saved accounts, newest first.

Returns

  • list[SavedAccount]: The accounts, with the signed-in one marked active.

Raises

  • OvokConfigError: The client signs in with client_secret.

switch()

switch(account_id: str) -> None

Make a saved account the signed-in one.

Parameters

NameTypeDefaultDescription
account_idstrThe account's id, its profile reference.

Raises

  • OvokAccountError: The account is not saved, or its session expired.
  • OvokConfigError: The client signs in with client_secret.

remove()

remove(account_id: str, *, options: RequestOptions | None = None) -> None

Sign a saved account out on the server and forget it.

Removing the signed-in account switches to the next live one, or signs out.

Parameters

NameTypeDefaultDescription
account_idstrThe account's id, its profile reference.
optionsRequestOptions | NoneNonePer-request options; timeout overrides the client's.

Raises

  • OvokAccountError: The account is not saved.
  • OvokConfigError: The client signs in with client_secret.
  • OvokError: The server could not end the account's session.

SessionResource

SessionResource(http: HttpClient, session: UserSession | None)

The current user session and the accounts saved on this client.

Created by Ovok; access it as ovok.session.

Parameters

NameTypeDefaultDescription
httpHttpClientThe client's HTTP client.
sessionUserSession | NoneThe user session; None for a machine client.

current()

current() -> Session | None

Return the stored session.

Returns

  • Session | None: The session, or None when no user is signed in or the client is a machine client.

on_change()

on_change(listener: SessionChangeListener) -> Callable[[], None]

Call listener with the new session, or None, on sign-in, account switch and sign-out.

Parameters

NameTypeDefaultDescription
listenerSessionChangeListenerCalled with the session that is now current.

Returns

  • Callable[[], None]: A function that stops the calls; for a machine client it does nothing.

Last updated on

On this page