DownstreamWebApi.CallWebApiForUserAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CallWebApiForUserAsync(String, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal, StringContent) |
Calls the downstream web API for the user, based on a description of the downstream web API in the configuration. |
CallWebApiForUserAsync<TInput,TOutput>(String, TInput, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal) |
Calls a downstream web API consuming JSON with some data and returns data. |
CallWebApiForUserAsync(String, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal, StringContent)
Calls the downstream web API for the user, based on a description of the downstream web API in the configuration.
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)
Parameters
- serviceName
- String
Name of the service describing the downstream web API. There can
be several configuration named sections mapped to a DownstreamWebApiOptions,
each for one downstream web API. You can pass-in null, but in that case calledDownstreamWebApiOptionsOverride
needs to be set.
- authenticationScheme
- String
Authentication scheme. If null, will use OpenIdConnectDefault.AuthenticationScheme if called from a web app, and JwtBearerDefault.AuthenticationScheme if called from a web API.
- calledDownstreamWebApiOptionsOverride
- Action<DownstreamWebApiOptions>
Overrides the options proposed in the configuration described
by serviceName
.
- user
- ClaimsPrincipal
[Optional] Claims representing a user. This is useful on platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HttpContext.
- content
- StringContent
HTTP context in the case where HttpMethod is Patch, Post, Put.
Returns
An HttpResponseMessage that the application will process.
Implements
Applies to
CallWebApiForUserAsync<TInput,TOutput>(String, TInput, String, Action<DownstreamWebApiOptions>, ClaimsPrincipal)
Calls a downstream web API consuming JSON with some data and returns data.
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)
Type Parameters
- TInput
Input type.
- TOutput
Output type.
Parameters
- serviceName
- String
Name of the service describing the downstream web API. There can
be several configuration named sections mapped to a DownstreamWebApiOptions,
each for one downstream web API. You can pass-in null, but in that case downstreamWebApiOptionsOverride
needs to be set.
- input
- TInput
Input parameter to the downstream web API.
- authenticationScheme
- String
Authentication scheme. If null, will use OpenIdConnectDefault.AuthenticationScheme if called from a web app, and JwtBearerDefault.AuthenticationScheme if called from a web API.
- downstreamWebApiOptionsOverride
- Action<DownstreamWebApiOptions>
Overrides the options proposed in the configuration described
by serviceName
.
- user
- ClaimsPrincipal
[Optional] Claims representing a user. This is useful in platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HttpContext.
Returns
The value returned by the downstream web API.