UsernamePasswordCredential Class

Definition

Enables authentication to Azure Active Directory using a user's username and password. If the user has MFA enabled this credential will fail to get a token throwing an AuthenticationFailedException. Also, this credential requires a high degree of trust and is not recommended outside of prototyping when more secure credentials can be used.

public class UsernamePasswordCredential : Azure.Core.TokenCredential
type UsernamePasswordCredential = class
    inherit TokenCredential
Public Class UsernamePasswordCredential
Inherits TokenCredential
Inheritance
UsernamePasswordCredential

Constructors

UsernamePasswordCredential()

Protected constructor for mocking

UsernamePasswordCredential(String, String, String, String)

Creates an instance of the UsernamePasswordCredential with the details needed to authenticate against Azure Active Directory with a simple username and password.

UsernamePasswordCredential(String, String, String, String, TokenCredentialOptions)

Creates an instance of the UsernamePasswordCredential with the details needed to authenticate against Azure Active Directory with a simple username and password.

UsernamePasswordCredential(String, String, String, String, UsernamePasswordCredentialOptions)

Creates an instance of the UsernamePasswordCredential with the details needed to authenticate against Azure Active Directory with a simple username and password.

Methods

Authenticate(CancellationToken)

Authenticates the user using the specified username and password.

Authenticate(TokenRequestContext, CancellationToken)

Authenticates the user using the specified username and password.

AuthenticateAsync(CancellationToken)

Authenticates the user using the specified username and password.

AuthenticateAsync(TokenRequestContext, CancellationToken)

Authenticates the user using the specified username and password.

GetToken(TokenRequestContext, CancellationToken)

Obtains a token for a user account, authenticating them using the given username and password. Note: This will fail with an AuthenticationFailedException if the specified user account has MFA enabled. This method is called automatically by Azure SDK client libraries. You may call this method directly, but you must also handle token caching and token refreshing.

GetTokenAsync(TokenRequestContext, CancellationToken)

Obtains a token for a user account, authenticating them using the given username and password. Note: This will fail with an AuthenticationFailedException if the specified user account has MFA enabled. This method is called automatically by Azure SDK client libraries. You may call this method directly, but you must also handle token caching and token refreshing.

Applies to