refreshOAuthToken method
Future<McpOAuthTokenGrant>
refreshOAuthToken(
- McpOAuthTokenGrant grant, {
- required McpOAuthClientAuthentication clientAuthentication,
- Iterable<
String> ? scopes, - Map<
String, String> headers = const <String, String>{}, - Duration timeout = const Duration(seconds: 30),
- int maxResponseBytes = 64 * 1024,
Refreshes a resource-bound OAuth grant without changing MCP session state.
Implementation
Future<McpOAuthTokenGrant> refreshOAuthToken(
McpOAuthTokenGrant grant, {
required McpOAuthClientAuthentication clientAuthentication,
Iterable<String>? scopes,
Map<String, String> headers = const <String, String>{},
Duration timeout = const Duration(seconds: 30),
int maxResponseBytes = 64 * 1024,
}) {
_throwIfClosed();
if (!grant.isForResource(endpoint)) {
throw McpOAuthTokenException(
'OAuth token grant is not valid for this MCP resource.',
endpoint: endpoint,
);
}
return _runTrackedOAuthHttpOperation(
(onRequestOpened) => refreshMcpOAuthToken(
grant,
clientAuthentication: clientAuthentication,
scopes: scopes,
httpClient: _httpClient,
headers: headers,
timeout: timeout,
maxResponseBytes: maxResponseBytes,
onRequestOpened: onRequestOpened,
),
);
}