Overview
Theevents client provides real-time streaming of authorization events via Server-Sent Events (SSE). Consume events with an async generator via stream(), or use the subscribe() convenience wrapper for callback-based consumption.
Access the events client via client.events.
Stream
Open an SSE connection and yield authorization events as an async generator. The connection remains open until you break out of the loop or the server closes it.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
event_types | list[str] | None | No | Filter to specific event types. If omitted, all types are streamed. |
since | str | None | No | ISO 8601 timestamp to replay events from (for catch-up after disconnection). |
GrantexEvent
| Field | Type | Description |
|---|---|---|
id | str | Unique event identifier. |
type | str | Event type (see Event types below). |
timestamp | str | ISO 8601 timestamp when the event occurred. |
data | dict | Event payload. Shape varies by event type. |
Subscribe
Subscribe to events with a callback function. Returns an unsubscribe callable to close the connection. This is a convenience wrapper aroundstream().
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
handler | Callable[[GrantexEvent], None] | Yes | Callback invoked for each event. |
event_types | list[str] | None | No | Filter to specific event types. |
since | str | None | No | ISO 8601 timestamp to replay events from. |