The Azure Identity library provides Microsoft Entra ID token authentication support across the Azure SDK with a comprehensive set of TokenCredential implementations.
—
DEPRECATED: Authenticates using username and password credentials. This credential type is deprecated due to lack of multifactor authentication support.
Provides username and password authentication for legacy scenarios.
/**
* Username password authentication credential
* @deprecated Does not support multifactor authentication (MFA)
*/
@Deprecated
class UsernamePasswordCredential implements TokenCredential {
Mono<AccessToken> getToken(TokenRequestContext request);
AccessToken getTokenSync(TokenRequestContext request);
Mono<AuthenticationRecord> authenticate(TokenRequestContext request);
Mono<AuthenticationRecord> authenticate();
}
@Deprecated
class UsernamePasswordCredentialBuilder extends AadCredentialBuilderBase<UsernamePasswordCredentialBuilder> {
UsernamePasswordCredentialBuilder username(String username);
UsernamePasswordCredentialBuilder password(String password);
UsernamePasswordCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions tokenCachePersistenceOptions);
UsernamePasswordCredentialBuilder additionallyAllowedTenants(String... additionallyAllowedTenants);
UsernamePasswordCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants);
UsernamePasswordCredential build();
}Usage Examples:
import com.azure.identity.UsernamePasswordCredential;
import com.azure.identity.UsernamePasswordCredentialBuilder;
// DEPRECATED - Not recommended for production use
TokenCredential credential = new UsernamePasswordCredentialBuilder()
.clientId("your-client-id")
.tenantId("your-tenant-id")
.username("user@example.com")
.password("password")
.build();
// Interactive authentication to get AuthenticationRecord
AuthenticationRecord record = credential.authenticate().block();This credential is deprecated because it does not support:
Recommended Alternatives:
InteractiveBrowserCredential for user authenticationDeviceCodeCredential for device-based authenticationClientSecretCredential for service principal authenticationMay throw AuthenticationRequiredException when interactive authentication is required due to security policies.
Install with Tessl CLI
npx tessl i tessl/maven-com-azure--azure-identitydocs