Language

IAuthorizationHeaderProvider2.CreateAuthorizationHeaderInformationAsync Method

Definition

Rich-result counterpart of CreateAuthorizationHeaderAsync(IEnumerable<String>, AuthorizationHeaderProviderOptions, ClaimsPrincipal, CancellationToken): creates an authorization header for calling a protected web API on behalf of a user or the application and returns the full AuthorizationHeaderInformation on success, with metadata and (when the protocol is bound) the binding certificate populated. On failure the AuthorizationHeaderError carries the token-acquisition metadata and structured failure details when available.

public System.Threading.Tasks.Task<Microsoft.Identity.Abstractions.OperationResult<Microsoft.Identity.Abstractions.AuthorizationHeaderInformation,Microsoft.Identity.Abstractions.AuthorizationHeaderError>> CreateAuthorizationHeaderInformationAsync(System.Collections.Generic.IEnumerable<string> scopes, Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions? options = default, System.Security.Claims.ClaimsPrincipal? claimsPrincipal = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateAuthorizationHeaderInformationAsync : seq<string> * Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions * System.Security.Claims.ClaimsPrincipal * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Identity.Abstractions.OperationResult<Microsoft.Identity.Abstractions.AuthorizationHeaderInformation, Microsoft.Identity.Abstractions.AuthorizationHeaderError>>
Public Function CreateAuthorizationHeaderInformationAsync (scopes As IEnumerable(Of String), Optional options As AuthorizationHeaderProviderOptions = Nothing, Optional claimsPrincipal As ClaimsPrincipal = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of OperationResult(Of AuthorizationHeaderInformation, AuthorizationHeaderError))

Parameters

scopes
IEnumerable<String>

The scopes for which to request the authorization header. Provide a single scope if the header needs to be created on behalf of an application.

options
AuthorizationHeaderProviderOptions

The AuthorizationHeaderProviderOptions containing information about the API to be called and token acquisition settings. If not provided, the header will be for a bearer token.

claimsPrincipal
ClaimsPrincipal

Inbound authentication elements. In a web API, this is usually the result of the validation of a token. In a web app, this would be information about the signed-in user. This is not useful in daemon applications. In Microsoft.Identity.Web you rarely need to provide this parameter as it's inferred from the context.

cancellationToken
CancellationToken

A token to cancel the operation.

Returns

An OperationResult<TResult,TError> containing the AuthorizationHeaderInformation on success, or an AuthorizationHeaderError on failure.

Applies to