AuthenticationContext.AcquireTokenAsync Method

Definition

Overloads

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

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, 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, IClientAssertionCertificate, UserAssertion, Boolean)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. For more details, see https://aka.ms/adal-net-on-behalf-of

AcquireTokenAsync(String, String, UserAssertion)

Acquires security token from the authority.

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, UserAssertion)

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

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, 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, Boolean)

Acquire a security token for the application (without a user) from the authority while enabling simplified Azure AD certificate roll over. For more details, see https://aka.ms/adal-net-client-credentials IMPORTANT: this flow isn’t enabled on the service at the time of this SDK release (ADAL.Net 3.19).

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

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, System.Threading.SynchronizationContext synchronizationContext = null);
member this.AcquireTokenAsync : string * string * Uri * Microsoft.IdentityModel.Clients.ActiveDirectory.IPlatformParameters * Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier * string * string * System.Threading.SynchronizationContext -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
String

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

clientId
String

Identifier of the client requesting the token.

redirectUri
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
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
String

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

synchronizationContext
SynchronizationContext

Optional SynchronizationContext for ensuring interactive calls are executed on the UI thread.

Returns

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

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
String

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

clientId
String

Identifier of the client requesting the token.

redirectUri
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
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
String

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

Returns

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

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
String

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

clientId
String

Identifier of the client requesting the token.

redirectUri
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
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

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

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
String

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

clientId
String

Identifier of the client requesting the token.

redirectUri
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

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

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
String

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

clientId
String

Identifier of the client requesting the token.

redirectUri
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

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

AcquireTokenAsync(String, IClientAssertionCertificate, UserAssertion, Boolean)

Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. For more details, see https://aka.ms/adal-net-on-behalf-of

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, bool sendX5c);
member this.AcquireTokenAsync : string * Microsoft.IdentityModel.Clients.ActiveDirectory.IClientAssertionCertificate * Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion * bool -> System.Threading.Tasks.Task<Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult>

Parameters

resource
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.

sendX5c
Boolean

This parameter enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. This saves the application admin from the need to explicitly manage the certificate rollover (either via portal or powershell/CLI operation)

Returns

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

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
String

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

clientId
String

Identifier of the client requesting the token.

userAssertion
UserAssertion

The assertion to use for token acquisition.

Returns

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

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
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

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

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
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

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

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
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

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

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
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

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

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
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

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

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
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

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

AcquireTokenAsync(String, IClientAssertionCertificate, Boolean)

Acquire a security token for the application (without a user) from the authority while enabling simplified Azure AD certificate roll over. For more details, see https://aka.ms/adal-net-client-credentials IMPORTANT: this flow isn’t enabled on the service at the time of this SDK release (ADAL.Net 3.19).

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

Parameters

resource
String

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

clientCertificate
IClientAssertionCertificate

The client certificate to use for token acquisition.

sendX5c
Boolean

This parameter enables application developers to achieve easy certificates roll-over in Azure AD: setting this parameter to true will send the public certificate to Azure AD along with the token request, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. This saves the application admin from the need to explicitly manage the certificate rollover (either via portal or powershell/CLI operation)

Returns

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

Applies to