# MSAL UsernamePasswordCredential

{% hint style="info" %}
**UsernamePasswordCredential** in <https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python>

Authenticates a user with a username and password.

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 **incompatible with 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](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/sign-up-organization) for more information about account types.
{% endhint %}

More examples regarding using automated SAML assertion to retrieve OAuth tokens in [java](https://docs.jianny.net/work/azure/app-registration-auths/graph-ropc-federated-account/java "mention")and [python](https://docs.jianny.net/work/azure/app-registration-auths/graph-ropc-federated-account/python "mention")
