Language

MicrosoftIdentityMessageHandlerOptions Class

Definition

Configuration options for MicrosoftIdentityMessageHandler authentication. Inherits from AuthorizationHeaderProviderOptions to enable compatibility with existing extension methods such as WithAgentIdentity() and WithUserAgentIdentity().

public class MicrosoftIdentityMessageHandlerOptions : Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions
type MicrosoftIdentityMessageHandlerOptions = class
    inherit AuthorizationHeaderProviderOptions
Public Class MicrosoftIdentityMessageHandlerOptions
Inherits AuthorizationHeaderProviderOptions
Inheritance
MicrosoftIdentityMessageHandlerOptions

Examples

Basic usage with scopes:

var options = new MicrosoftIdentityMessageHandlerOptions
{
    Scopes = { "https://graph.microsoft.com/.default" }
};

Usage with extension methods:

var options = new MicrosoftIdentityMessageHandlerOptions
{
    Scopes = { "api://myapi/.default" }
};
options.WithAgentIdentity("agent-guid");

Constructors

Name Description
MicrosoftIdentityMessageHandlerOptions()

Initializes a new instance of the MicrosoftIdentityMessageHandlerOptions class.

MicrosoftIdentityMessageHandlerOptions(MicrosoftIdentityMessageHandlerOptions)

Initializes a new instance of the MicrosoftIdentityMessageHandlerOptions class by copying values from an existing instance.

Properties

Name Description
AcquireTokenOptions

Options related to token acquisition.

(Inherited from AuthorizationHeaderProviderOptions)
BaseUrl

Base URL for the called downstream web API. For instance "https://graph.microsoft.com/beta/".

(Inherited from AuthorizationHeaderProviderOptions)
CustomizeHttpRequestMessage

Provides an opportunity for the caller app to customize the HttpRequestMessage. For example, to customize the headers. This is called after the message was formed, including the Authorization header, and just before the message is sent.

(Inherited from AuthorizationHeaderProviderOptions)
HttpMethod

HTTP method used to call this downstream web API (by default Get).

(Inherited from AuthorizationHeaderProviderOptions)
OnAfterAuthHeaderCreation

Provides an opportunity for the caller app to customize the HttpRequestMessageafter the authorization header (including the Authorization header) has been set, and just before the message is sent β€” the point at which the finalized request can be read or adjusted. Provided for naming symmetry with OnBeforeAuthHeaderCreation; it shares this timing with the pre-existing CustomizeHttpRequestMessage, which continues to be invoked for backwards compatibility. When both are set they run at the same point, so callers should not depend on their relative order. Do not modify material bound by a request-binding protocol (SHR q/h/b) here, since it runs after signing; use OnBeforeAuthHeaderCreation for that.

(Inherited from AuthorizationHeaderProviderOptions)
OnBeforeAuthHeaderCreation

Provides an opportunity for the caller app to customize the HttpRequestMessagebefore the authorization header is created. At this point the Authorization header is not yet present. Use this to shape the request that a request-binding protocol signs β€” for example a SignedHttpRequest (SHR) that binds the query, headers, or body (the q/h/b claims) to the token β€” so the signature covers the finalized request. To observe or adjust the request after the header has been created, use OnAfterAuthHeaderCreation (or CustomizeHttpRequestMessage).

(Inherited from AuthorizationHeaderProviderOptions)
ProtocolScheme

Name of the protocol scheme used to create the authorization header. By default: "Bearer".

(Inherited from AuthorizationHeaderProviderOptions)
RelativePath

Path relative to the BaseUrl (for instance "me").

(Inherited from AuthorizationHeaderProviderOptions)
RequestAppToken

Describes if the downstream API is called on behalf of the calling service itself (App token) or on behalf of a user processed by the service (user token). If true, the token is requested on behalf of the app. Otherwise, it on-behalf of the user.

(Inherited from AuthorizationHeaderProviderOptions)
Scopes

Gets or sets the scopes to request for the token.

Methods

Name Description
Clone()

Clone the options (to be able to override them).

(Inherited from AuthorizationHeaderProviderOptions)
CloneInternal()

Clone the options (to be able to override them).

(Inherited from AuthorizationHeaderProviderOptions)
GetApiUrl()

Return the downstream web API URL.

(Inherited from AuthorizationHeaderProviderOptions)

Applies to

See also