Skip to main content
POST
/
v1
/
auth
/
token
import olira

olira.init(api_key="YOUR_API_KEY")
tok = olira.get_patient_token(patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82")
print(tok.access_token[:20], "…", tok.expires_in)
PatientToken(
    access_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
    token_type="bearer",
    expires_in=900,
    scopes=["sdk:state-read", "sdk:event-log"],
)
olira.get_patient_token(patient_id: str) -> PatientToken
Requires scope: sdk:patient-token Use as Bearer token with the Patient State MCP server.

Parameters

patient_id
str
required
Olira patient id to lock the token to.

Returns

PatientToken
access_token
str
JWT string.
token_type
str
Typically “bearer”.
expires_in
int
Lifetime in seconds.
scopes
list[str]
Granted OAuth scopes for this token.

Raises

ExceptionWhen
AuthErrorHTTP 401 or 403 — invalid API key or insufficient OAuth scope for this endpoint.
ValidationErrorHTTP 400, 404, or 422 — malformed JSON, unknown patient, or validation failure (message includes response excerpt).
ServerErrorHTTP 409 (e.g. conflicting external identifier) or repeated 5xx after retries; includes status_code when applicable.
RateLimitErrorHTTP 429 — rate limited; check retry_after (seconds).
NetworkErrorConnection timeout, DNS failure, or read error after retries.
import olira

olira.init(api_key="YOUR_API_KEY")
tok = olira.get_patient_token(patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82")
print(tok.access_token[:20], "…", tok.expires_in)
PatientToken(
    access_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
    token_type="bearer",
    expires_in=900,
    scopes=["sdk:state-read", "sdk:event-log"],
)