> ## Documentation Index
> Fetch the complete documentation index at: https://ai.easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ProtectedResourceMetadataClient

> Fetches an RFC 9728 protected resource metadata document over the handler-free `'OAuth'` named [HttpClient](https://learn.microsoft.com/dotnet/api/system.net...

## Definition

**Assembly:** Microsoft.OData.Mcp.Authentication.dll

**Namespace:** Microsoft.OData.Mcp.Authentication.Outbound

**Inheritance:** System.Object

## Syntax

```csharp theme={null}
Microsoft.OData.Mcp.Authentication.Outbound.ProtectedResourceMetadataClient
```

## Summary

Fetches an RFC 9728 protected resource metadata document over the handler-free `"OAuth"` named
[HttpClient](https://learn.microsoft.com/dotnet/api/system.net.http.httpclient), treating every well-known failure per `AUTH-14`: 401, 403, 404, and a
failed parse are logged and swallowed; a timeout or 5xx is retried once before it becomes fatal.

## Remarks

A new `"OAuth"` client is requested from [IHttpClientFactory](https://learn.microsoft.com/dotnet/api/system.net.http.ihttpclientfactory) on every call rather than
cached, matching the "Two named HttpClients" table in `specs/v3/AUTHENTICATION.md`: this client
carries no delegating handler and is safe to create per request. Response bodies are never logged.

## Examples

```csharp theme={null}
var client = new ProtectedResourceMetadataClient(httpClientFactory, logger);
var metadata = await client.TryGetAsync(new Uri("https://api.example.com/.well-known/oauth-protected-resource"), cancellationToken);
if (metadata is not null &amp;&amp; metadata.AuthorizationServers?.Count &gt; 0)
{
    // Continue discovery against metadata.AuthorizationServers[0].
}
```

## Constructors

### &#x20;.ctor

Initializes a new instance of the [ProtectedResourceMetadataClient](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/ProtectedResourceMetadataClient.md) class.

#### Syntax

```csharp theme={null}
public ProtectedResourceMetadataClient(System.Net.Http.IHttpClientFactory httpClientFactory, Microsoft.Extensions.Logging.ILogger<Microsoft.OData.Mcp.Authentication.Outbound.ProtectedResourceMetadataClient> logger)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `httpClientFactory` | `System.Net.Http.IHttpClientFactory` | The factory used to create the `"OAuth"` named client per call. |
| `logger` | `Microsoft.Extensions.Logging.ILogger<Microsoft.OData.Mcp.Authentication.Outbound.ProtectedResourceMetadataClient>` | The logger this instance records non-fatal well-known outcomes to. |

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *httpClientFactory* or *logger* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public Object()
```

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual string ToString()
```

#### Returns

Type: `string?`

### &#x20;TryGetAsync

Attempts to fetch and parse the RFC 9728 protected resource metadata document at a well-known URL.

#### Syntax

```csharp theme={null}
public System.Threading.Tasks.Task<ModelContextProtocol.Authentication.ProtectedResourceMetadata> TryGetAsync(System.Uri url, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `url` | `System.Uri` | The absolute protected resource metadata URL. |
| `cancellationToken` | `System.Threading.CancellationToken` | The token that cancels the request. |

#### Returns

Type: `System.Threading.Tasks.Task<ModelContextProtocol.Authentication.ProtectedResourceMetadata?>`
The parsed document on a `200` response with a well-formed body; otherwise [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
after a 401, 403, 404, unparseable body, or any other non-retryable non-success status.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *url* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). |
| `ArgumentException` | Thrown when *url* is not an absolute URI, or is an `http` URI whose host is not loopback. |
| `OutboundDiscoveryException` | Thrown when the request times out, fails at the transport, or returns a 5xx status, after one retry. |

#### Examples

```csharp theme={null}
var metadata = await client.TryGetAsync(server.ProtectedResourceMetadataUri, cancellationToken);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.