title: Dynamics365/O365 login for WinForms Application active MFA
body: <p>I am working on an application that connects to Dynamics 365 and creates contacts there, for example.
  My question now is how to configure the login.
  For testing, multi-factor authentication is disabled and it works so far. However, in the production system, MFA will be active.
  I want to avoid users using an app password.
  Is there a way to pop up the standard O365 login popup window from within a WinForms application?
  Unfortunately I couldn't find anything about it.
  What would make the most sense here?
  Thats my code so far:</p>
  <pre><code>        public CrmServiceClient connect_crm()
      {
          string ConnectionString = &quot;AuthType = OAuth; &quot; +
                &quot;Username= &quot; + textBox1.Text + &quot;;&quot; +
                &quot;Password=&quot; + textBox2.Text + &quot;;&quot; +
                &quot;Url=https://company.dynamics.com;&quot; +
                &quot;RedirectUri=app://;&quot; + 
                &quot;AppId=XXXXXXXX-XXXXX-XXXX-XXXX-XXXXXXXXXXXXX;&quot; +
                &quot;LoginPrompt=Auto&quot;;
          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
          svc = new CrmServiceClient(ConnectionString);
          try
          {
              if (svc != null &amp;&amp; svc.IsReady)
              {
                  label4.BackColor = Color.LightGreen;
                  label4.Text = &quot;Connected&quot;;
                  CreateContact2(svc);
              }
          }
          catch (Exception ex)
          {
  
              MessageBox.Show(ex.Message);
          }
          return svc;
      }
  </code></pre>