ovok_sdk.auth.session

The signed-in user's session and its JSON conversions.

  • 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 JSON conversions.

OvokReference

OvokReference(reference: str, display: str | None = None)

A FHIR reference to a resource.

Attributes

NameTypeDescription
referencestrRelative reference, such as Patient/123.
displaystr | NoneHuman-readable label, when the API sends one.

Session

Session(
    access_token: str,
    refresh_token: str | None,
    expires_at_ms: int,
    project: OvokReference,
    profile: OvokReference,
)

The signed-in user's tokens, project and profile.

Attributes

NameTypeDescription
access_tokenstrBearer token; never shown in repr.
refresh_tokenstr | NoneToken that renews the session, if any; never shown in repr.
expires_at_msintAccess-token expiry in epoch milliseconds.
projectOvokReferenceThe project the user signed in to.
profileOvokReferenceThe user's profile resource, such as a Patient or Practitioner.

is_stale_at()

is_stale_at(now_ms: int) -> bool

Whether the access token is within a minute of expiring at now_ms.

session_from_login()

session_from_login(tokens: Mapping[str, Any], now_ms: int) -> Session

Build a session from a sign-in response.

Parameters

NameTypeDefaultDescription
tokensMapping[str, Any]The camelCase body every Ovok sign-in route answers with.
now_msintCurrent time in epoch milliseconds.

Returns

  • Session: The new session.

session_after_refresh()

session_after_refresh(session: Session, response: TokenResponse, now_ms: int) -> Session

Return session with the tokens from a refresh, keeping the old refresh token if none came back.

reference_from_json()

reference_from_json(value: Mapping[str, Any]) -> OvokReference

Read a reference from its FHIR JSON shape.

reference_to_json()

reference_to_json(reference: OvokReference) -> dict[str, Any]

Write a reference in its FHIR JSON shape.

Last updated on

On this page