OzoneTool.fromOAuthSession constructor
- OAuthSession session, {
- OAuthClient? oauthClient,
- String? ozoneDid,
- Map<
String, String> ? headers, - Protocol? protocol,
- String? service,
- String? relayService,
- Duration? timeout,
- RetryStrategy? retryConfig,
- GetClient? getClient,
- 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,
);