title: Authorization to azure active directory through web api
body: <p>I've read a lot of docs but maybe missed something. What I want to do is to pass username and password to Web API, get token in response and to use it to access other secured parts of the Web API (non-interactive authorization)</p>
  
  <p>I found that it is possible to do only with native clients (desktop, mobile application)</p>
  
  <pre><code>List&lt;string&gt; scopes = new List&lt;string&gt;()
  {
      "https://mydomain.onmicrosoft.com/myapp/access-as_user"
  };
  string clientId = _azureAdOptions.Value.ClientId;
  string aadInstance = "https://login.microsoftonline.com/{0}/v2.0";
  string tanent = "organizations";
  string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tanent);
  
  var secureStringPass = new NetworkCredential("", pass).SecurePassword;
  PublicClientApplication _app = new PublicClientApplication(clientId, authority);
  var result = await _app.AcquireTokenByUsernamePasswordAsync(scopes, usr, secureStringPass);
  </code></pre>
  
  <p>The code above workd in natove clieant, but when I move it to my WebAPI application it gives me</p>
  
  <blockquote>
    <p>MsalServiceException: AADSTS70002: The request body must contain the
    following parameter: 'client_secret or client_assertion'</p>
  </blockquote>
  
  <p>Is it impossible to get access token form web api this way?</p>