or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-authentication-flows.mdauthorization-code-authentication.mdazure-developer-cli-authentication.mdazure-pipelines-authentication.mdclient-assertion-authentication.mdconfiguration-and-utilities.mdcredential-chaining.mddefault-azure-credential.mddeveloper-tool-credentials.mdenvironment-credential.mdindex.mdinteractive-user-authentication.mdmanaged-identity-credential.mdservice-principal-authentication.mdshared-token-cache-authentication.mdusername-password-authentication.mdvisual-studio-code-authentication.md

username-password-authentication.mddocs/

0

# Username Password Authentication

1

2

**DEPRECATED:** Authenticates using username and password credentials. This credential type is deprecated due to lack of multifactor authentication support.

3

4

## Capabilities

5

6

### Username Password Credential

7

8

Provides username and password authentication for legacy scenarios.

9

10

```java { .api }

11

/**

12

* Username password authentication credential

13

* @deprecated Does not support multifactor authentication (MFA)

14

*/

15

@Deprecated

16

class UsernamePasswordCredential implements TokenCredential {

17

Mono<AccessToken> getToken(TokenRequestContext request);

18

AccessToken getTokenSync(TokenRequestContext request);

19

Mono<AuthenticationRecord> authenticate(TokenRequestContext request);

20

Mono<AuthenticationRecord> authenticate();

21

}

22

23

@Deprecated

24

class UsernamePasswordCredentialBuilder extends AadCredentialBuilderBase<UsernamePasswordCredentialBuilder> {

25

UsernamePasswordCredentialBuilder username(String username);

26

UsernamePasswordCredentialBuilder password(String password);

27

UsernamePasswordCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions tokenCachePersistenceOptions);

28

UsernamePasswordCredentialBuilder additionallyAllowedTenants(String... additionallyAllowedTenants);

29

UsernamePasswordCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants);

30

UsernamePasswordCredential build();

31

}

32

```

33

34

**Usage Examples:**

35

36

```java

37

import com.azure.identity.UsernamePasswordCredential;

38

import com.azure.identity.UsernamePasswordCredentialBuilder;

39

40

// DEPRECATED - Not recommended for production use

41

TokenCredential credential = new UsernamePasswordCredentialBuilder()

42

.clientId("your-client-id")

43

.tenantId("your-tenant-id")

44

.username("user@example.com")

45

.password("password")

46

.build();

47

48

// Interactive authentication to get AuthenticationRecord

49

AuthenticationRecord record = credential.authenticate().block();

50

```

51

52

## Deprecation Notice

53

54

This credential is deprecated because it does not support:

55

- Multifactor authentication (MFA)

56

- Conditional access policies

57

- Modern security requirements

58

59

**Recommended Alternatives:**

60

- `InteractiveBrowserCredential` for user authentication

61

- `DeviceCodeCredential` for device-based authentication

62

- `ClientSecretCredential` for service principal authentication

63

64

## Exception Handling

65

66

May throw `AuthenticationRequiredException` when interactive authentication is required due to security policies.