Namespaces
Session
Learn how to read the current session, react when it changes and switch between the accounts signed in on this client.
- Stable unknown
- Release candidate not available
- Development since 0.2.0-dev.34+53a6a64
ovok.session holds the signed-in user's session and every account signed in to on this client. Each sign-in saves its account under ovok:<tenant_code>:saved-accounts in storage, next to the session.
React to sign-in and sign-out
stop = ovok.session.on_change(lambda session: print(session.profile if session else "signed out"))
stop()- The listener gets the new session on sign-in and account switch, and
Noneon sign-out. currentreturns the stored session, orNone.
Switch accounts
for account in ovok.session.saved_accounts.list():
print(account.id, account.active, account.expired)
ovok.session.saved_accounts.switch("Patient/123")switchraisesOvokAccountErrorwith codeaccount_not_foundoraccount_expired. An account expires when its refresh token is refused; signing in again renews it.removeends the account's session on the server with that account's own token, then forgets it. Removing the active account switches to the next live one, or signs out.- A machine client has no session:
currentreturnsNoneandsaved_accountsraisesOvokConfigError.
See also
Last updated on