title: Incorrect username or password while getting Access Token in Azure
body: <p>Here's my code for getting the access token:</p>
  
  <pre><code>HttpClient clie = new HttpClient();
      string tokenEndpoint = "https://login.microsoftonline.com/{directoryID}/oauth2/token";
      var body = "resource=https://analysis.windows.net/powerbi/api&amp;client_id=clientID&amp;grant_type=password&amp;username=myADusername&amp;password=myADpassword";
     var stringContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");
  
   var result = await clie.PostAsync(tokenEndpoint, stringContent).ContinueWith&lt;string&gt;((response) =&gt;
                  {
                      return response.Result.Content.ReadAsStringAsync().Result;
                  });
  
                  JObject jobject = JObject.Parse(result);
  
                  var token = jobject["access_token"].Value&lt;string&gt;();
  </code></pre>
  
  <p>I am using my Azure AD username and password to get the token.  I have used the same credentials in my MVC app <code>var credential = new UserPasswordCredential(Username,Password);</code> which works fine.  But in this .NET core 2.0 app it gives me an error saying invalid grant. Invalid username or password. These are the same credentials that I've used to get the token, the grant type is set to password.  What is wrong with what I am doing?</p>