Language

IAuthorizationHeaderProvider2.CreateAuthorizationHeaderInformationForUserAsync Method

Definition

Rich-result counterpart of CreateAuthorizationHeaderForUserAsync(IEnumerable<String>, AuthorizationHeaderProviderOptions, ClaimsPrincipal, CancellationToken): creates the authorization header used to call a protected web API on behalf of a user 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>> CreateAuthorizationHeaderInformationForUserAsync(System.Collections.Generic.IEnumerable<string> scopes, Microsoft.Identity.Abstractions.AuthorizationHeaderProviderOptions? authorizationHeaderProviderOptions = default, System.Security.Claims.ClaimsPrincipal? claimsPrincipal = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateAuthorizationHeaderInformationForUserAsync : 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 CreateAuthorizationHeaderInformationForUserAsync (scopes As IEnumerable(Of String), Optional authorizationHeaderProviderOptions As AuthorizationHeaderProviderOptions = Nothing, Optional claimsPrincipal As ClaimsPrincipal = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of OperationResult(Of AuthorizationHeaderInformation, AuthorizationHeaderError))

Parameters

scopes
IEnumerable<String>

Scopes for which to request the authorization header.

authorizationHeaderProviderOptions
AuthorizationHeaderProviderOptions

Information about the API that will be called (for some protocols like PoP), and token acquisition options.

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

Cancellation token.

Returns

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

Applies to