title: AADSTS50001: Getting exception while trying to access token from Azure AD by using ADAL from Console client
body: <p>Getting exception while trying to access token from Azure AD by using ADAL from Console client.</p>
  
  <p><strong>Steps:</strong></p>
  
  <ol>
  <li>I have configured Azure AD with my Web API application localhost:44307.</li>
  <li>Added the required configuration for Client Id, Client Key.</li>
  <li>Followed the work around by changing manifest suggested in this link.
  <a href="https://www.google.com/search?q=AADSTS50001+%2B+azure+AD+athentication&amp;oq=AADSTS50001+%2B+azure+AD+athentication&amp;aqs=chrome..69i57.10202j0j7&amp;sourceid=chrome&amp;espv=210&amp;es_sm=93&amp;ie=UTF-8#q=AADSTS50001&amp;safe=active" rel="nofollow noreferrer">https://www.google.com/search?q=AADSTS50001+%2B+azure+AD+athentication&amp;oq=AADSTS50001+%2B+azure+AD+athentication&amp;aqs=chrome..69i57.10202j0j7&amp;sourceid=chrome&amp;espv=210&amp;es_sm=93&amp;ie=UTF-8#q=AADSTS50001&amp;safe=active</a></li>
  </ol>
  
  <p><strong>ADAL Version Using:</strong> Microsoft.IdentityModel.Clients.ActiveDirectory 2.6.0-alpha</p>
  
  <p><strong>Console App Code:</strong></p>
  
  <pre><code>void GetToken()
  {
      clientId = "be6b055a-4efc-222a-2187-49657e6f4f1b";
      string ClientKey = "c/uIMlsqn9SzJLKKyBle42Ym+tgcaC2tbMlWxJQawE";
      string ClientCredential clientCred = new ClientCredential(clientId, ClientKey);
  
      authenticationContext = new AuthenticationContext("https://login.windows.net/MyDevAD.onmicrosoft.com");                
      authenticationResult = authenticationContext.AcquireToken("https://mylocalwebapiapp.com/", clientCred);
      ....
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Fiddler Input:</strong></p>
  
  <pre><code>POST https: //login.windows.net/MyDevAD.onmicrosoft.com/oauth2/token HTTP/1.1
  Content-Type: application/x-www-form-urlencoded
  client-request-id: 53262b17-1234-4ed9-bdb3-748d332eb44b
  return-client-request-id: true
  x-client-SKU: .NET
  x-client-Ver: 2.6.0.0
  x-client-CPU: x64
  x-client-OS: Microsoft Windows NT 6.3.9600.0
  Host: login.windows.net
  Content-Length: 185
  Expect: 100-continue
  Connection: Keep-Alive
  
  grant_type=client_credentials&amp;resource=https%3A%2F%2Flocalhost%3A44307%2F&amp;client_id=be6b055a-4efc-408a-8187-42137e6f4f1b&amp;client_secret=c%2FuIMlsqn9SzJLKKyBle123Ym%2BtgcaC3tbMlWxJQawE%3D
  </code></pre>
  
  <hr>
  
  <p><strong>Fiddler Output:</strong></p>
  
  <pre><code>HTTP/1.1 400 Bad Request
  Cache-Control: no-cache, no-store
  Pragma: no-cache
  Content-Type: application/json; charset=utf-8
  Expires: -1
  Set-Cookie: x-ms-gateway-slice=ProductionB; path=/
  x-ms-request-id: e89741b2-570d-44f6-9e71-6533b083abcd
  client-request-id: 35262b17-4771-4ed9-bdb3-748d332eb33b
  X-Content-Type-Options: nosniff
  X-Powered-By: ARR/3.0
  X-Powered-By: ASP.NET
  Date: Tue, 01 Apr 2014 19:05:51 GMT
  Content-Length: 438
  
  {"error":"invalid_resource","error_description":"AADSTS50001: Resource 'https://mylocalwebapiapp.com/' is not registered for the account.\r\nTrace ID: e89741b2-570d-44f6-9e71-6533b083cdad\r\nCorrelation ID: 35262b17-4771-4ed9-cddb3-748d332eb44b\r\nTimestamp: 2014-04-01 19:05:53Z","error_codes":[50001],"timestamp":"2014-04-01 19:05:53Z","trace_id":"e89741b2-570d-44f6-9e71-6533b083cdad","correlation_id":"35262b17-4771-4ed9-bdb3-748d332eb44b"}
  </code></pre>
  
  <hr>
  
  <p><strong>Note:</strong> Posted URLS and ID's are faked ones.</p>