UsernamePasswordCredential Class

Authenticates a user with a username and password.

In general, Microsoft doesn't recommend this kind of authentication, because it's less secure than other authentication flows.

Authentication with this credential is not interactive, so it is not compatible with any form of multi-factor authentication or consent prompting. The application must already have consent from the user or a directory admin.

This credential can only authenticate work and school accounts; Microsoft accounts are not supported. See Azure Active Directory documentation for more information about account types.

Inheritance
azure.identity._internal.interactive.InteractiveCredential
UsernamePasswordCredential

Constructor

UsernamePasswordCredential(client_id: str, username: str, password: str, **kwargs: Any)

Parameters

client_id
str
Required

the application's client ID

username
str
Required

the user's username (usually an email address)

password
str
Required

the user's password

authority
str

Authority of an Azure Active Directory endpoint, for example "login.microsoftonline.com", the authority for Azure Public Cloud (which is the default). AzureAuthorityHosts defines authorities for other clouds.

tenant_id
str

tenant ID or a domain associated with a tenant. If not provided, defaults to the "organizations" tenant, which supports only Azure Active Directory work or school accounts.

cache_persistence_options
TokenCachePersistenceOptions

configuration for persistent token caching. If unspecified, the credential will cache tokens in memory.