title: Azure AD authentication with Username and Password and also have MFA
body: <p>I implemented Azure AD Authentication using MSAL (RPOC) and .net 4.6.1 . I am able to authenticate the user if the user's MFA isn't enabled. If it is enabled then I receive an Error</p>
  <pre><code>**Microsoft.Identity.Client.MsalUiRequiredException: 'AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000003-0000-0000-c000-000000000000'.**
  </code></pre>
  <p>This is the code I am using.</p>
  <pre><code> public async Task&lt;string&gt; ValidateUserAsync()
      {
  
          string authority = string.Format(&quot;https://login.microsoftonline.com/{0}&quot;, tenant);
          string[] scopes = new string[] { &quot;User.Read&quot; };
          IPublicClientApplication app;
          app = PublicClientApplicationBuilder.Create(clientId)
                    .WithAuthority(authority)
                    .Build();
          var securePassword = new SecureString();
          foreach (char c in password.ToCharArray())  
              securePassword.AppendChar(c);  
          var result = await app.AcquireTokenByUsernamePassword(scopes, username, securePassword).ExecuteAsync();
          return result.IdToken;
      }
  </code></pre>
  <p>How do I implement MFA? Like receive sms of code and pass the same to this?
  I will be having my own UI to accept the code</p>