get<T> method
Future<XRPCResponse<T> >
get<T>(
- NSID methodId, {
- String? service,
- Map<
String, String> ? headers, - Map<
String, dynamic> ? parameters, - ResponseDataBuilder<
T> ? to, - ResponseDataAdaptor? adaptor,
- GetClient? client,
Implementation
Future<xrpc.XRPCResponse<T>> get<T>(
final NSID methodId, {
final String? service,
final Map<String, String>? headers,
final Map<String, dynamic>? parameters,
final xrpc.ResponseDataBuilder<T>? to,
final xrpc.ResponseDataAdaptor? adaptor,
final xrpc.GetClient? client,
}) async {
await _maybeRefreshBeforeSend();
await _ensureOAuthSessionResolved();
final resolvedService = service ?? this.service;
final endpoint = _endpointFor(resolvedService, methodId);
final callerHeaders = {..._headers ?? const {}, ...headers ?? const {}};
final callerHasAuth = _hasAuthorization(callerHeaders);
return await _challenge.execute(
() async {
// When the caller already supplied an `Authorization` header (e.g. a
// service-auth Bearer token for the video service), leave it intact:
// do not attach the OAuth DPoP `Authorization`/proof that would
// clobber it.
final oauthHeaders = callerHasAuth
? const <String, String>{}
: await _oauthAuthHeaders(endpoint, 'GET');
return await xrpc.query(
methodId,
protocol: _protocol,
service: resolvedService,
headers: {...callerHeaders, ...oauthHeaders},
parameters: parameters,
to: to,
adaptor: adaptor,
timeout: _timeout,
// Legacy Bearer path still uses the sync header builder; OAuth
// headers are already merged above, so only attach the builder
// when there is no OAuth manager.
headerBuilder: oAuthSessionManager == null ? _buildAuthHeader : null,
getClient: client ?? _getClient,
);
},
isProcedure: false,
nsid: methodId.toString(),
onUpdateDpopNonce: (h) => _onUpdateDpopNonce(endpoint, h),
onUnauthorized: _onUnauthorized,
);
}