UsernamePasswordCredential Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Enables authentication to Microsoft Entra ID 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
Constructors
UsernamePasswordCredential() |
Protected constructor for mocking |
UsernamePasswordCredential(String, String, String, String, TokenCredentialOptions) |
Creates an instance of the UsernamePasswordCredential with the details needed to authenticate against Microsoft Entra ID 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 Microsoft Entra ID with a simple username and password. |
UsernamePasswordCredential(String, String, String, String) |
Creates an instance of the UsernamePasswordCredential with the details needed to authenticate against Microsoft Entra ID 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 provided username and password. Acquired tokens are cached by the credential instance. Token lifetime and refreshing is handled automatically. Where possible, reuse credential instances to optimize cache effectiveness. |
GetTokenAsync(TokenRequestContext, CancellationToken) |
Obtains a token for a user account, authenticating them using the provided username and password. Acquired tokens are cached by the credential instance. Token lifetime and refreshing is handled automatically. Where possible, reuse credential instances to optimize cache effectiveness. |