DownstreamWebApiGenericExtensions.CallWebApiForUserAsync<TOutput> 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.
Caution
Use IDownstreamApi.CallWebApiForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.
Call a web API endpoint with an HttpGet, and return strongly typed data.
[System.Obsolete("Use IDownstreamApi.CallWebApiForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.", false)]
public static System.Threading.Tasks.Task<TOutput?> CallWebApiForUserAsync<TOutput> (this Microsoft.Identity.Web.IDownstreamWebApi downstreamWebApi, string serviceName, Action<Microsoft.Identity.Web.DownstreamWebApiOptions>? downstreamWebApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, string? authenticationScheme = default) where TOutput : class;
[<System.Obsolete("Use IDownstreamApi.CallWebApiForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.", false)>]
static member CallWebApiForUserAsync : Microsoft.Identity.Web.IDownstreamWebApi * string * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal * string -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
<Extension()>
Public Function CallWebApiForUserAsync(Of TOutput As Class) (downstreamWebApi As IDownstreamWebApi, serviceName As String, Optional downstreamWebApiOptionsOverride As Action(Of DownstreamWebApiOptions) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional authenticationScheme As String = Nothing) As Task(Of TOutput)
Type Parameters
- TOutput
Output type.
Parameters
- downstreamWebApi
- IDownstreamWebApi
The downstream web API.
- 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.
- 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.
- 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.
Returns
The value returned by the downstream web API.
- Attributes