Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.AspNetCore.dll Namespace: Microsoft.OData.Mcp.AspNetCore.Authentication Inheritance: System.Object

Syntax

Summary

What an API publishes about how to sign in to it: the RFC 8414 authorization servers that issue its tokens, the scopes a client should ask for, and which route bases the published document covers.

Remarks

Nothing here describes how the API validates a token. That stays with whatever authentication handler the app already registered; this type only describes the API to a client that has not signed in yet. The default route base is the application root, which is the usual shape of an API that is not sharing a host with MVC.

Examples

Constructors

.ctor

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

AnnotateChallenges

Gets or sets a value indicating whether a 401 under a covered route base has its WWW-Authenticate challenge rewritten to carry resource_metadata.

Syntax

Property Value

Type: bool Defaults to true.

Remarks

Turn this off only when the app already emits an RFC 9728 hint of its own. A client that never sees resource_metadata still finds the document through the two well-known URLs, but it spends an extra request doing so.

AuthorizationServers

Gets the RFC 8414 issuer URLs of the authorization servers that issue tokens for this API, in the order a client should try them.

Syntax

Property Value

Type: System.Collections.Generic.List<System.Uri> At least one entry is required. Each must be absolute and https; http is accepted only for loopback hosts so a test or a local identity provider still works.

Examples

Prefixes

Gets the route bases the published documents cover, in the same form Endpoint Routing and Minimal APIs accept.

Syntax

Property Value

Type: System.Collections.Generic.List<string> Empty by default, which means the application root only. A non-empty list replaces that default.

Examples

Remarks

An empty string and / are the application root, matching MapGroup("") and AddRouteComponents(string.Empty, model). odata and /odata/ both mean the /odata base. Nested bases such as api/v1 are valid. A whitespace-only entry is rejected by ProtectedResourceMetadataOptions.Validate: it is not a route base.

ResourceDocumentation

Gets or sets the URL of a page a developer can read to learn how to call this API.

Syntax

Property Value

Type: System.Uri?

ResourceName

Gets or sets the human-readable name of this API, shown to a user during consent.

Syntax

Property Value

Type: string?

ScopesSupported

Gets the scope values a client should request to call this API.

Syntax

Property Value

Type: System.Collections.Generic.List<string> Empty by default, in which case a client falls back to whatever scopes its operator configured.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?

Validate

Fails the host when the published document would be unusable.

Syntax

Exceptions

Examples

Remarks

Called by ProtectedResourceMetadataStartupFilter before the pipeline is built, so a misconfigured API refuses to start rather than serving a document that sends every client to an authorization server that does not exist. An empty string and / in ProtectedResourceMetadataOptions.Prefixes are the application root and pass.