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
| Name | Type | Default | Description |
|---|---|---|---|
http | HttpClient | The client's HTTP client. | |
session | UserSession | None | The 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 markedactive.
Raises
OvokConfigError: The client signs in withclient_secret.
switch()
switch(account_id: str) -> NoneMake a saved account the signed-in one.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
account_id | str | The account's id, its profile reference. |
Raises
OvokAccountError: The account is not saved, or its session expired.OvokConfigError: The client signs in withclient_secret.
remove()
remove(account_id: str, *, options: RequestOptions | None = None) -> NoneSign 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
| Name | Type | Default | Description |
|---|---|---|---|
account_id | str | The account's id, its profile reference. | |
options | RequestOptions | None | None | Per-request options; timeout overrides the client's. |
Raises
OvokAccountError: The account is not saved.OvokConfigError: The client signs in withclient_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
| Name | Type | Default | Description |
|---|---|---|---|
http | HttpClient | The client's HTTP client. | |
session | UserSession | None | The user session; None for a machine client. |
current()
current() -> Session | NoneReturn 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
| Name | Type | Default | Description |
|---|---|---|---|
listener | SessionChangeListener | Called 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