title: Getting AccessToken from Azure Ad via UserName & Password
body: <p>I have a Native Client registered in our Azure AD.</p>
  
  <p>When i'm using </p>
  
  <pre><code>var ar = _context.AcquireToken(resource, clientId, returnUri);
  </code></pre>
  
  <p>It opens the Prompt for Username and Password. If I enter them correctly I get a valid AccessToken and everything is fine.</p>
  
  <p>When I'm now trying to enter the credentials in code, via UserCrendtial:</p>
  
  <pre><code>var credential = new UserCredential("username", "password");
  
  var ar = _context.AcquireToken(resource, clientId, credential);
  </code></pre>
  
  <p>But both resulting in an Error when I'm trying it with the directly entered Credentials.</p>
  
  <blockquote>
    <p>AADSTS65001: No permission to access user information is configured
    for '4915f024-blah-blah-blah-f580ab5b0487' application, or it is
    expired or revoked.</p>
  </blockquote>
  
  <p>I have tried the normal <code>(string, string)</code> and the <code>(string, SecureString)</code> overload of the UserCredential.
  I have tried it with the exact same combination of username &amp; password, which I have entered in the Prompt, of the first overload from AcquireToken.</p>
  
  <p>I have also tried to give the Application in Azure all the Delegated Permissions:</p>
  
  <ul>
  <li>Read directory data</li>
  <li>Read and write directory data</li>
  <li>Access your organization's directory</li>
  </ul>
  
  <p>And added Windows Azure Service Management API Application with Permission:</p>
  
  <ul>
  <li>Access Azure Service Management </li>
  </ul>
  
  <p>Nothing helped.</p>
  
  <p>As a sidenote, the Application in the Azure has permissions to a SharePoint O365 Tenant. To Read and Write ListItems I don't know if this is relevant. The Resource i'm passing through is the SharePoint Adress.</p>
  
  <p>I don't need any user access over the Graph Api to the Azure. I only need that AccessToken to access our SharePoint Online.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><strong>Architecture:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/K1UAv.png" alt="enter image description here"></p>
  
  <p><strong>Description:</strong></p>
  
  <p>We have a Web Api Project which handles the User Authorization, Load Balancing etc. This Web Api Project, will be queried by either Native Dekstop Clients or Hybrid HTML5 &amp; Javascript Mobile Device Apps.</p>
  
  <p>The Web Api Project needs to Read, Create, Update &amp; Delete Data from our SharePoint O365 Tenant. So this where I need the AccessToken to init a ClientContext or send i via a rest response.</p>
  
  <p>Since the Web Api handles the User authorization, there is an endpoint for users to login already and in this endpoint I want to acquire the Token. That's why I want it to be silent, because the "flexbile browser popup" is already there.</p>
  
  <p>Maybe I don't need in this scenario the Token acquiring with Username / Password, but then I don't know how to configure the Azure App right to work with all the different native client's.</p>