AuthenticationContext.AcquireTokenAsync Method

Definition

Overloads

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier, String, String)

Acquires an access token from the authority on behalf of a user, passing in the necessary claims for authentication. It requires using a user token previously received.

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier, String)

Acquires security token from the authority.

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier)

Acquires security token from the authority.

AcquireTokenAsync(String, String, Uri, IPlatformParameters)

Acquires security token from the authority.

AcquireTokenAsync(String, String, UserAssertion)

Acquires security token from the authority.

AcquireTokenAsync(String, ClientAssertion, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

AcquireTokenAsync(String, ClientCredential, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

AcquireTokenAsync(String, IClientAssertionCertificate)

Acquires security token from the authority.

AcquireTokenAsync(String, ClientCredential)

Acquires security token from the authority.

AcquireTokenAsync(String, ClientAssertion)

Acquires security token from the authority.

AcquireTokenAsync(String, IClientAssertionCertificate, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier, String, String)

Acquires an access token from the authority on behalf of a user, passing in the necessary claims for authentication. It requires using a user token previously received.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, string clientId, Uri redirectUri, Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters parameters, Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier userId, string extraQueryParameters, string claims);
member this.AcquireTokenAsync : string * string * Uri * Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters * Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier * string * string -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>
Public Function AcquireTokenAsync (resource As String, clientId As String, redirectUri As Uri, parameters As IPlatformParameters, userId As UserIdentifier, extraQueryParameters As String, claims As String) As Task(Of AuthenticationResult)

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientId
System.String

Identifier of the client requesting the token.

redirectUri
System.Uri

Address to return to upon receiving a response from the authority.

parameters
IPlatformParameters

Instance of PlatformParameters containing platform specific arguments and information.

userId
UserIdentifier

Identifier of the user token is requested for. This parameter can be UserIdentifier.Any.

extraQueryParameters
System.String

This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.

claims
System.String

Additional claims that are needed for authentication. Acquired from the AdalClaimChallengeException

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time.

Applies to

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier, String)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, string clientId, Uri redirectUri, Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters parameters, Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier userId, string extraQueryParameters);
member this.AcquireTokenAsync : string * string * Uri * Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters * Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier * string -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>
Public Function AcquireTokenAsync (resource As String, clientId As String, redirectUri As Uri, parameters As IPlatformParameters, userId As UserIdentifier, extraQueryParameters As String) As Task(Of AuthenticationResult)

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientId
System.String

Identifier of the client requesting the token.

redirectUri
System.Uri

Address to return to upon receiving a response from the authority.

parameters
IPlatformParameters

Parameters needed for interactive flow requesting authorization code. Pass an instance of PlatformParameters.

userId
UserIdentifier

Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user. If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be UserIdentifier.Any.

extraQueryParameters
System.String

This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token, its expiration time, user information.

Applies to

AcquireTokenAsync(String, String, Uri, IPlatformParameters, UserIdentifier)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, string clientId, Uri redirectUri, Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters parameters, Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier userId);
member this.AcquireTokenAsync : string * string * Uri * Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters * Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>
Public Function AcquireTokenAsync (resource As String, clientId As String, redirectUri As Uri, parameters As IPlatformParameters, userId As UserIdentifier) As Task(Of AuthenticationResult)

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientId
System.String

Identifier of the client requesting the token.

redirectUri
System.Uri

Address to return to upon receiving a response from the authority.

parameters
IPlatformParameters

An object of type PlatformParameters which may pass additional parameters used for authorization.

userId
UserIdentifier

Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user. If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be UserIdentifier.Any.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token, its expiration time, user information.

Applies to

AcquireTokenAsync(String, String, Uri, IPlatformParameters)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, string clientId, Uri redirectUri, Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters parameters);
member this.AcquireTokenAsync : string * string * Uri * Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>
Public Function AcquireTokenAsync (resource As String, clientId As String, redirectUri As Uri, parameters As IPlatformParameters) As Task(Of AuthenticationResult)

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientId
System.String

Identifier of the client requesting the token.

redirectUri
System.Uri

Address to return to upon receiving a response from the authority.

parameters
IPlatformParameters

An object of type PlatformParameters which may pass additional parameters used for authorization.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token, its expiration time, user information.

Applies to

AcquireTokenAsync(String, String, UserAssertion)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, string clientId, Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion userAssertion);
member this.AcquireTokenAsync : string * string * Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientId
System.String

Identifier of the client requesting the token.

userAssertion
UserAssertion

The assertion to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.

Applies to

AcquireTokenAsync(String, ClientAssertion, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertion clientAssertion, Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion userAssertion);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertion * Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientAssertion
ClientAssertion

The client assertion to use for token acquisition.

userAssertion
UserAssertion

The user assertion (token) to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time.

Applies to

AcquireTokenAsync(String, ClientCredential, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential clientCredential, Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion userAssertion);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential * Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientCredential
ClientCredential

The client credential to use for token acquisition.

userAssertion
UserAssertion

The user assertion (token) to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time.

Applies to

AcquireTokenAsync(String, IClientAssertionCertificate)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.IClientAssertionCertificate clientCertificate);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.IClientAssertionCertificate -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>
Public Function AcquireTokenAsync (resource As String, clientCertificate As IClientAssertionCertificate) As Task(Of AuthenticationResult)

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientCertificate
IClientAssertionCertificate

The client certificate to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.

Applies to

AcquireTokenAsync(String, ClientCredential)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential clientCredential);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientCredential
ClientCredential

The client credential to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.

Applies to

AcquireTokenAsync(String, ClientAssertion)

Acquires security token from the authority.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertion clientAssertion);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertion -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientAssertion
ClientAssertion

The client assertion to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.

Applies to

AcquireTokenAsync(String, IClientAssertionCertificate, UserAssertion)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received.

public System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult> AcquireTokenAsync (string resource, Microsoft.IdentityModel.Clients.ActiveDirectory.IClientAssertionCertificate clientCertificate, Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion userAssertion);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.IClientAssertionCertificate * Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
System.String

Identifier of the target resource that is the recipient of the requested token.

clientCertificate
IClientAssertionCertificate

The client certificate to use for token acquisition.

userAssertion
UserAssertion

The user assertion (token) to use for token acquisition.

Returns

System.Threading.Tasks.Task<AuthenticationResult>

It contains Access Token and the Access Token's expiration time.

Applies to