title: Authenticating with Windows Azure Active Directory directly without opening web browser
body: <p>I referred <a href="https://stackoverflow.com/questions/16141640/how-to-validate-azure-active-directory-user-credential">this question</a> and <a href="http://social.msdn.microsoft.com/Forums/windowsazure/en-US/246e4244-5a6c-43a8-a05d-88744196740c/azure-ad-azure-acs-windows-8-xaml-app" rel="nofollow noreferrer">this MSDN post</a>, but couldn't get the problem fixed.</p>
  
  <p>Below code demonstrates how to perform the WAAD authentication using web browser:</p>
  
  <pre><code>AuthenticationContext auth = new AuthenticationContext("https://login.windows.net/" + myDomain);
  AuthenticationResult result = auth.AcquireToken(resource, clientID, resourceAppIDURI);
  </code></pre>
  
  <p>This opens a browser and user is asked to enter the details which works fine.</p>
  
  <p>However, I have a GUI client, which can take username/password/domain on its own. So the intention is to collect the details from GUI client and directly provide to the WAAD server and get the user authenticated.</p>
  
  <p>How to do that?</p>
  
  <p>Just looking at the overloads of <code>AcquireToken()</code>, I did get some clue (this can be wrong as well):</p>
  
  <pre><code>AuthenticationResult AcquireToken (string resource, Credential credential);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>AuthenticationResult AcquireToken (string authorizationCode, string redirectUri, ClientCredential credential);
  </code></pre>
  
  <p>But I fail to understand, how to create the <code>class ClientCredential</code> (subclass of <code>Credential</code>). Important to note that this class belongs to the <code>namespace Microsoft.WindowsAzure.ActiveDirectory.Authentication</code>.<br>
  Below are its constructors:</p>
  
  <pre><code>ClientCredential(string clientId, SecureString secureClientSecret);
  ClientCredential(string clientId, string clientSecret);
  </code></pre>
  
  <p>Searching online, I couldn't get much answers, I did get <a href="http://code.msdn.microsoft.com/Multi-Tenant-Cloud-8015b84b" rel="nofollow noreferrer">this link</a>. But again the part of <code>SecureString</code> is a mystery to me. How the username/password/domain can be communicated using <code>SecureString</code>?</p>