File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/ModelContextProtocol/Authentication Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1- using ModelContextProtocol . Utils ;
1+ using Microsoft . Extensions . Logging ;
2+ using Microsoft . Extensions . Logging . Abstractions ;
23using ModelContextProtocol . Utils . Json ;
34using System . Text . Json ;
45
@@ -10,15 +11,18 @@ namespace ModelContextProtocol.Authentication;
1011public class AuthorizationHelpers
1112{
1213 private readonly HttpClient _httpClient ;
14+ private readonly ILogger _logger ;
1315 private static readonly Lazy < HttpClient > _defaultHttpClient = new ( ( ) => new HttpClient ( ) ) ;
1416
1517 /// <summary>
1618 /// Initializes a new instance of the <see cref="AuthorizationHelpers"/> class.
1719 /// </summary>
1820 /// <param name="httpClient">The HTTP client to use for requests. If null, a default HttpClient will be used.</param>
19- public AuthorizationHelpers ( HttpClient ? httpClient = null )
21+ /// <param name="logger">The logger to use. If null, a NullLogger will be used.</param>
22+ public AuthorizationHelpers ( HttpClient ? httpClient = null , ILogger ? logger = null )
2023 {
2124 _httpClient = httpClient ?? _defaultHttpClient . Value ;
25+ _logger = logger ?? NullLogger . Instance ;
2226 }
2327
2428 /// <summary>
@@ -42,8 +46,9 @@ public AuthorizationHelpers(HttpClient? httpClient = null)
4246 McpJsonUtilities . JsonContext . Default . ProtectedResourceMetadata ,
4347 cancellationToken ) . ConfigureAwait ( false ) ;
4448 }
45- catch ( Exception )
49+ catch ( Exception ex )
4650 {
51+ _logger . LogError ( ex , $ "Failed to fetch protected resource metadata from { metadataUrl } ") ;
4752 return null ;
4853 }
4954 }
You can’t perform that action at this time.
0 commit comments