BasicAuthenticationCredential Class
- java.
lang. Object - com.
azure. core. credential. BasicAuthenticationCredential
- com.
Implements
public class BasicAuthenticationCredential
implements TokenCredential
The BasicAuthenticationCredential is used to authenticate and authorize requests made to Azure services using the Basic authentication scheme. Basic Authentication is a simple authentication scheme that uses a combination of a username and password.
Note that Basic Authentication is generally considered less secure than other authentication methods, such as Azure Active Directory (AAD) authentication. It is recommended to use Azure Active Directory (Azure AD) authentication via TokenCredential whenever possible, especially for production environments.
Sample: Azure SAS Authentication
The following code sample demonstrates the creation of a BasicAuthenticationCredential, using username and password
BasicAuthenticationCredential basicAuthenticationCredential =
new BasicAuthenticationCredential("<username>", "<password>");
Constructor Summary
Constructor | Description |
---|---|
BasicAuthenticationCredential(String username, String password) |
Creates a basic authentication credential. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Mono<Access |
getToken(TokenRequestContext request)
Asynchronously get a token for a given resource/audience. |
Methods inherited from java.lang.Object
Constructor Details
BasicAuthenticationCredential
public BasicAuthenticationCredential(String username, String password)
Creates a basic authentication credential.
Parameters:
Method Details
getToken
public Mono
Asynchronously get a token for a given resource/audience. 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.
Parameters:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for