AuthenticationContext Class

Definition

The AuthenticationContext class retrieves authentication tokens from Azure Active Directory and ADFS services.

public sealed class AuthenticationContext
type AuthenticationContext = class
Public NotInheritable Class AuthenticationContext
Inheritance
AuthenticationContext

Constructors

AuthenticationContext(String)

Constructor to create the context with the address of the authority. Using this constructor will turn ON validation of the authority URL by default if validation is supported for the authority address.

AuthenticationContext(String, Boolean)

Constructor to create the context with the address of the authority and flag to turn address validation off. Using this constructor, address validation can be turned off. Make sure you are aware of the security implication of not validating the address.

AuthenticationContext(String, Boolean, TokenCache)

Constructor to create the context with the address of the authority and flag to turn address validation off. Using this constructor, address validation can be turned off. Make sure you are aware of the security implication of not validating the address.

AuthenticationContext(String, Boolean, TokenCache, IHttpClientFactory)

Constructor to create the context with the address of the authority, flag to turn address validation off and custom IHttpClientFactory. Make sure you are aware of the security implication of not validating the address.

AuthenticationContext(String, TokenCache)

Constructor to create the context with the address of the authority. Using this constructor will turn ON validation of the authority URL by default if validation is supported for the authority address.

Properties

Authority

Gets address of the authority to issue token.

CorrelationId

Gets or sets correlation Id which would be sent to the service with the next request. Correlation Id is to be used for diagnostics purposes.

ExtendedLifeTimeEnabled

Used to set the flag for AAD extended lifetime

TokenCache

ADAL's token cache, where tokens are automatically saved. On some platforms, e.g. iOS, Android and UWP, the TokenCache is backed by a persistent store which is implemeted by ADAL. On other platforms, e.g. .net and .net core - the developer is responsible for implementing a persistent store. If not using a persistent store, an in-memory store is used, which is destroyed once the application stops. To find out more about leveraging the token cache visit: https://aka.ms/adal-net-using-cached-tokens To find out more about implementing a persistent store, visit: https://aka.ms/adal-net-cache-serialization

ValidateAuthority

Gets a value indicating whether address validation is ON or OFF.

Methods

AcquireDeviceCodeAsync(String, String)

Acquires device code from the authority.

AcquireDeviceCodeAsync(String, String, String)

Acquires device code from the authority.

AcquireTokenAsync(String, ClientAssertion)

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)

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)

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, IClientAssertionCertificate, 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, 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, Uri, IPlatformParameters)

Acquires security token from the authority.

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

Acquires security token from the authority.

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

Acquires security token from the authority.

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

Acquires security token from the authority.

AcquireTokenByAuthorizationCodeAsync(String, Uri, ClientAssertion)

Acquires security token from the authority using an authorization code previously received. This method does not lookup the token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, ClientAssertion, String)

In a Web App, attemps to acquire a security token from the authority using an authorization code previously received (after a call to one of the overrides of AcquireTokenByAuthorizationCodeAsync). For more details see https://aka.ms/adal-net-authorization-code. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, ClientCredential)

Acquires security token from the authority using authorization code previously received. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, ClientCredential, String)

Acquires security token from the authority using an authorization code previously received. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, IClientAssertionCertificate)

Acquires security token from the authority using an authorization code previously received. This method does not lookup the token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, IClientAssertionCertificate, String)

Acquires security token from the authority using an authorization code previously received. This method does not lookup the token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByAuthorizationCodeAsync(String, Uri, IClientAssertionCertificate, String, Boolean)

In a Web App, attempts to acquire a security token from the authority using an authorization code previously received (after a call to one of the overrides of AcquireTokenByAuthorizationCodeAsync). For more details see https://aka.ms/adal-net-authorization-code. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByDeviceCodeAsync(DeviceCodeResult)

Acquires security token from the authority using an device code previously received. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenByDeviceCodeAsync(DeviceCodeResult, CancellationToken)

Acquires security token from the authority using an device code previously received. This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as AcquireTokenSilentAsync(String, String, UserIdentifier).

AcquireTokenSilentAsync(String, ClientAssertion, UserIdentifier)

Acquires security token without asking for user credential.

AcquireTokenSilentAsync(String, ClientCredential, UserIdentifier)

Acquires security token without asking for user credential.

AcquireTokenSilentAsync(String, IClientAssertionCertificate, UserIdentifier)

Acquires security token without asking for user credential.

AcquireTokenSilentAsync(String, String)

Acquires security token without asking for user credential.

AcquireTokenSilentAsync(String, String, UserIdentifier)

Acquires security token without asking for user credential.

AcquireTokenSilentAsync(String, String, UserIdentifier, IPlatformParameters)

Acquires security token without asking for user credential.

GetAuthorizationRequestUrlAsync(String, String, Uri, UserIdentifier, String)

Gets URL of the authorize endpoint including the query parameters.

GetAuthorizationRequestUrlAsync(String, String, Uri, UserIdentifier, String, String)

Gets URL of the authorize endpoint including the query parameters.

Extension Methods

AcquireTokenAsync(AuthenticationContext, String, String, UserCredential)

Acquires security token from the authority.

Applies to