API referenceauth
ovok_sdk.auth.user_session
The signed-in user's session and its token refresh.
- Stable unknown
- Release candidate since 0.1.0-rc.4
- Development since 0.1.0-dev.25+2ba84b0
The signed-in user's session and its token refresh.
UserSession
UserSession(
store: SessionStore,
endpoint: TokenEndpoint,
settings: OvokSettings,
clock: Clock = epoch_ms,
)The signed-in user's tokens, kept in storage and refreshed a minute before they expire.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
store | SessionStore | Where the session is kept. | |
endpoint | TokenEndpoint | The OAuth token endpoint used to refresh. | |
settings | OvokSettings | The client's settings. | |
clock | Clock | epoch_ms | Current time in epoch milliseconds. |
current()
current() -> Session | NoneReturn the stored session, or None when no one is signed in.
begin()
begin(tokens: Mapping[str, Any]) -> SessionStart a session from a sign-in response and notify listeners.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tokens | Mapping[str, Any] | The camelCase body of an Ovok sign-in route. |
Returns
Session: The new session.
end()
end() -> NoneDelete the session and notify listeners.
on_change()
on_change(listener: Callable[[], None]) -> NoneCall listener whenever the session starts, refreshes or ends.
access_token()
access_token() -> str | NoneReturn the access token, refreshing it first when it is stale; None when signed out.
refresh()
refresh() -> boolExchange the refresh token for new tokens.
A refused refresh signs the user out and calls on_unauthenticated.
Returns
bool: True when the session was refreshed; False when there is nothing to refreshbool: or the refresh was refused.
Raises
OvokError: The refresh failed for another reason, such as an outage.
Last updated on