DownstreamWebApi.CallWebApiForUserAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| CallWebApiForUserAsync(String, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal, StringContent) |
根據設定中對下游網頁 API 的描述,呼叫使用者的下游網頁 API。 |
| CallWebApiForUserAsync<TInput,TOutput>(String, TInput, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal) |
呼叫一個下游的網頁 API,使用 JSON 並回傳部分資料。 |
CallWebApiForUserAsync(String, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal, StringContent)
根據設定中對下游網頁 API 的描述,呼叫使用者的下游網頁 API。
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> CallWebApiForUserAsync(string serviceName, string? authenticationScheme, Action<Microsoft.Identity.Web.DownstreamWebApiOptions>? calledDownstreamWebApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, System.Net.Http.StringContent? content = default);
abstract member CallWebApiForUserAsync : string * string * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal * System.Net.Http.StringContent -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
override this.CallWebApiForUserAsync : string * string * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal * System.Net.Http.StringContent -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function CallWebApiForUserAsync (serviceName As String, authenticationScheme As String, Optional calledDownstreamWebApiOptionsOverride As Action(Of DownstreamWebApiOptions) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional content As StringContent = Nothing) As Task(Of HttpResponseMessage)
參數
- serviceName
- String
描述下游網頁 API 的服務名稱。 可以有多個命名為 的配置區段對應到 一個 DownstreamWebApiOptions,每個區段對應一個下游的網頁 API。 你可以用 pass-in null,但那 calledDownstreamWebApiOptionsOverride 時必須設定。
- authenticationScheme
- String
認證方案。 若為空,則使用 OpenIdConnectDefault.AuthenticationScheme(從網頁應用程式呼叫),若從網頁 API 呼叫則使用 JwtBearerDefault.AuthenticationScheme。
- calledDownstreamWebApiOptionsOverride
- Action<DownstreamWebApiOptions>
覆蓋由 描述 serviceName的配置中提出的選項。
- user
- ClaimsPrincipal
[可選]代表使用者的主張。 這在像 Blazor 或 Azure Signal R 這類無法使用 HttpContext 的平台上非常有用。 在其他平台,函式庫會從 HttpContext 找到使用者。
- content
- StringContent
HTTP 上下文,當 HttpMethod 是 Patch、 Post、 Put。
傳回
而 HttpResponseMessage 申請會處理。
實作
適用於
CallWebApiForUserAsync<TInput,TOutput>(String, TInput, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal)
呼叫一個下游的網頁 API,使用 JSON 並回傳部分資料。
public System.Threading.Tasks.Task<TOutput?> CallWebApiForUserAsync<TInput,TOutput>(string serviceName, TInput input, string? authenticationScheme, Action<Microsoft.Identity.Web.DownstreamWebApiOptions>? downstreamWebApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default) where TOutput : class;
abstract member CallWebApiForUserAsync : string * 'Input * string * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
override this.CallWebApiForUserAsync : string * 'Input * string * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
Public Function CallWebApiForUserAsync(Of TInput, TOutput) (serviceName As String, input As TInput, authenticationScheme As String, Optional downstreamWebApiOptionsOverride As Action(Of DownstreamWebApiOptions) = Nothing, Optional user As ClaimsPrincipal = Nothing) As Task(Of TOutput)
類型參數
- TInput
輸入類型。
- TOutput
輸出類型。
參數
- serviceName
- String
描述下游網頁 API 的服務名稱。 可以有多個命名為 的配置區段對應到 一個 DownstreamWebApiOptions,每個區段對應一個下游的網頁 API。 你可以用 pass-in null,但那 downstreamWebApiOptionsOverride 時必須設定。
- input
- TInput
輸入參數到下游網頁 API。
- authenticationScheme
- String
認證方案。 若為空,則使用 OpenIdConnectDefault.AuthenticationScheme(從網頁應用程式呼叫),若從網頁 API 呼叫則使用 JwtBearerDefault.AuthenticationScheme。
- downstreamWebApiOptionsOverride
- Action<DownstreamWebApiOptions>
覆蓋由 描述 serviceName的配置中提出的選項。
- user
- ClaimsPrincipal
[可選]代表使用者的主張。 這在像 Blazor 或 Azure Signal R 這類無法使用 HttpContext 的平台上非常有用。 在其他平台,函式庫會從 HttpContext 找到使用者。
傳回
下游網頁 API 回傳的值。