title: Authenticate Microsoft Account user with ACS using REST
body: <p>I would like to leverage ACS to authenticate Windows Account users (and eventually users from other identity providers in the future) on a website.</p>
  
  <p>I have found a lot of resources regarding ACS, but most revolve around using WIF/using managed code in the UI layer in order to validate a user.  I'd like to avoid that.  Is it possible to retrieve a token from ACS by making a REST-based call to ACS using javascript/jQuery to retrieve a token for a Microsoft Account user?</p>
  
  <p>One example that I saw that came close, is this link, however this uses a service identity instead of leveraging identity providers.  <a href="http://code.msdn.microsoft.com/windowsazure/MVC4-Web-API-With-SWT-232d69da" rel="nofollow">http://code.msdn.microsoft.com/windowsazure/MVC4-Web-API-With-SWT-232d69da</a></p>
  
  <p>Here's my end goal:</p>
  
  <ol>
  <li>This website would have two layers, a UI layer (MVC 4) and a service layer (MVC WebAPI).  Both of these layers will need to scale independently of each other in Azure.</li>
  <li>I'd like to have the UI layer call ACS to determine if the current session is authenticated.  If it is, I'd like ACS to return a token to the client.  I'd like to store that token on the client as for use in step 3.</li>
  <li>Once the user has logged in, I'd like to have the client make a REST based calls to the service layer passing the Microsoft Account/ACS user token along in the header of each request, completely bypassing the UI layer for this second service request.  The service layer would authenticate the user with each request.</li>
  <li>The client would handle the response codes (200, 401, ect) from the Service layer by either redirecting to the login page, or by displaying the results.</li>
  </ol>
  
  <p>I am unsure about step 2.  How would the client browser retrieve a token from ACS that it can pass along to the Service layer?</p>
  
  <p>I essentially want to do what Vittorio describes <a href="http://msdn.microsoft.com/en-us/library/windowsazure/79e09d59-08b9-446a-8ead-209134a4326d" rel="nofollow">here</a>, but I want to use a MVC4 web app instead of a Windows 8 store app.</p>