Language

HttpRequestMessageAuthenticationExtensions.WithAuthenticationOptions メソッド

定義

オーバーロード

Name 説明
WithAuthenticationOptions(HttpRequestMessage, MicrosoftIdentityMessageHandlerOptions)

HTTP 要求の認証オプションを設定します。

WithAuthenticationOptions(HttpRequestMessage, Action<MicrosoftIdentityMessageHandlerOptions>)

デリゲートを使用して HTTP 要求の認証オプションを構成します。

WithAuthenticationOptions(HttpRequestMessage, MicrosoftIdentityMessageHandlerOptions)

HTTP 要求の認証オプションを設定します。

public static System.Net.Http.HttpRequestMessage WithAuthenticationOptions(this System.Net.Http.HttpRequestMessage request, Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions options);
static member WithAuthenticationOptions : System.Net.Http.HttpRequestMessage * Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions -> System.Net.Http.HttpRequestMessage
<Extension()>
Public Function WithAuthenticationOptions (request As HttpRequestMessage, options As MicrosoftIdentityMessageHandlerOptions) As HttpRequestMessage

パラメーター

request
HttpRequestMessage

構成する HTTP 要求メッセージ。

options
MicrosoftIdentityMessageHandlerOptions

この要求に適用する認証オプション。

返品

メソッドチェーンの同じ要求メッセージ。

例外

requestまたはoptionsがnullされたときにスローされます。

例

var options = new MicrosoftIdentityMessageHandlerOptions
{
    Scopes = { "https://graph.microsoft.com/.default" }
};
options.WithAgentIdentity("my-agent-guid");

var request = new HttpRequestMessage(HttpMethod.Get, "/me")
    .WithAuthenticationOptions(options);

注釈

このメソッドは、要求に設定されている既存の認証オプションをオーバーライドします。 options オブジェクトは、他の Microsoft Identity Web パッケージの拡張メソッドを使用してさらに構成できます。

適用対象

WithAuthenticationOptions(HttpRequestMessage, Action<MicrosoftIdentityMessageHandlerOptions>)

デリゲートを使用して HTTP 要求の認証オプションを構成します。

public static System.Net.Http.HttpRequestMessage WithAuthenticationOptions(this System.Net.Http.HttpRequestMessage request, Action<Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions> configure);
static member WithAuthenticationOptions : System.Net.Http.HttpRequestMessage * Action<Microsoft.Identity.Web.MicrosoftIdentityMessageHandlerOptions> -> System.Net.Http.HttpRequestMessage
<Extension()>
Public Function WithAuthenticationOptions (request As HttpRequestMessage, configure As Action(Of MicrosoftIdentityMessageHandlerOptions)) As HttpRequestMessage

パラメーター

request
HttpRequestMessage

構成する HTTP 要求メッセージ。

configure
Action<MicrosoftIdentityMessageHandlerOptions>

認証オプションを構成するデリゲート。

返品

メソッドチェーンの同じ要求メッセージ。

例外

requestまたはconfigureがnullされたときにスローされます。

例

var request = new HttpRequestMessage(HttpMethod.Get, "/api/users")
    .WithAuthenticationOptions(options =>
    {
        options.Scopes.Add("https://myapi.domain.com/user.read");
        options.WithAgentIdentity("agent-application-id");
        options.RequestAppToken = true;
    });

注釈

要求に認証オプションが既に構成されている場合、デリゲートは変更する既存のオプション オブジェクトを受け取ります。 それ以外の場合は、新しい MicrosoftIdentityMessageHandlerOptions インスタンスが作成され、デリゲートに渡されます。

このメソッドは、エージェント ID メソッドなど、他の Microsoft Identity Web パッケージから拡張メソッドを適用する必要がある場合に特に便利です。

適用対象