OzoneTool.fromOAuthSession constructor

OzoneTool.fromOAuthSession(
  1. OAuthSession session, {
  2. OAuthClient? oauthClient,
  3. String? ozoneDid,
  4. Map<String, String>? headers,
  5. Protocol? protocol,
  6. String? service,
  7. String? relayService,
  8. Duration? timeout,
  9. RetryStrategy? retryConfig,
  10. GetClient? getClient,
  11. PostClient? postClient,
})

Returns the new instance of OzoneTool.

Pass oauthClient to enable transparent token refresh; without it the session is used as-is and cannot be refreshed.

This builds a fresh oauth.OAuthSessionManager on every call, so a second client built this way for the same account does not share the session — and what it gets instead is worse than an independent client. Each manager holds its own copy of session, and a rotating refresh token is only honoured once: whichever manager refreshes first spends it, and the other then spends a wasted token request discovering that. It recovers — the rejected refresh falls back to whatever the shared oauth.OAuthClient's session store now holds — but only because both managers happen to read the same store, and each still keeps its own in-memory copy in the meantime. Build the manager yourself and pass it to OzoneTool.fromOAuth when more than one client shares an account.

ozoneDid names the Ozone instance to route tools.ozone.* to, as in OzoneTool.fromAtproto.

Implementation

factory OzoneTool.fromOAuthSession(
  final oauth.OAuthSession session, {
  final oauth.OAuthClient? oauthClient,
  final String? ozoneDid,
  final Map<String, String>? headers,
  final core.Protocol? protocol,
  final String? service,
  final String? relayService,
  final Duration? timeout,
  final core.RetryStrategy? retryConfig,
  final core.GetClient? getClient,
  final core.PostClient? postClient,
}) => OzoneTool.fromOAuth(
  oauth.OAuthSessionManager.fromSession(
    session,
    client: oauthClient,
    timeout: timeout,
  ),
  ozoneDid: ozoneDid,
  headers: headers,
  protocol: protocol,
  service: service,
  relayService: relayService,
  timeout: timeout,
  retryConfig: retryConfig,
  getClient: getClient,
  postClient: postClient,
);