Table of Contents

Event AuthFailed

Namespace
LMKit.Mcp.Client
Assembly
LM-Kit.NET.dll

Gets or sets a callback invoked when an authentication failure is detected.

public event EventHandler<McpAuthFailedEventArgs> AuthFailed

Returns

EventHandler<McpAuthFailedEventArgs>

An action that receives the HTTP status code (either 401 Unauthorized or 403 Forbidden). Default is null.

Examples

client.OnAuthFailed = statusCode => 
{
    Console.WriteLine($"Authentication failed with status {statusCode}");
    // Refresh token or prompt for new credentials
};

Remarks

Use this callback to detect authentication issues and take corrective action, such as refreshing tokens, prompting for credentials, or logging authentication failures.

This callback is invoked before the HTTP response is evaluated further, giving you an early opportunity to handle authentication problems. The request will still fail with an exception after this callback returns.