AtpAgent Type
Client agent for communicating with an AT Protocol Personal Data Server (PDS). Holds the HTTP client, base URL, optional authenticated session, and extra headers.
Create an agent with create or createWithClient, then authenticate with login. The agent's Session field is mutable: it is updated automatically on login and token refresh.
Example
let agent = AtpAgent.create "https://bsky.social"
let! session = AtpAgent.login "my-handle.bsky.social" "app-password-here" agent
Record fields
| Record Field |
Description
|
|
Custom authentication handler. When set, overrides the default Bearer token auth. The function receives the HttpRequestMessage (with Method and RequestUri already set) and should add appropriate Authorization/DPoP headers. Used by OAuth/DPoP bridge to inject DPoP-bound authentication.
|
The base URL of the PDS, always ending with a trailing slash (e.g. "https://bsky.social/"). Updated after login to point to the user's actual PDS (resolved from the DID document).
|
|
Full Usage:
ExtraHeaders
Field type: (string * string) list
|
Additional HTTP headers sent with every request (e.g. the
|
|
The HttpClient used for all HTTP requests to the PDS.
|
Full Usage:
OnSessionChanged
Field type: (unit -> unit) option
|
Called when session state changes (login, token refresh, session resume). Consumers can use this to persist sessions to disk or database.
|
|
Custom session refresh handler. When set, overrides the default app-password refresh
( |
|
|