title: How to get Access Token from ASP.Net Web API 2 via AngularJS $http?
body: <p>I try like this:</p>
  
  <pre><code>$http({ method: 'POST', url: '/token', data: { username: $scope.username, password: $scope.password, grant_type: 'password' } }).success(function (data, status, headers, config) {
      $scope.output = data;
  }).error(function (data, status, headers, config) {
      $scope.output = data;
  });
  </code></pre>
  
  <p>then tried changing the grant_type to a param:</p>
  
  <pre><code>$http({ method: 'POST', url: '/token', data: { username: $scope.username, password: $scope.password }, params: { grant_type: 'password' } }).success(function (data, status, headers, config) {
      $scope.output = data;
  }).error(function (data, status, headers, config) {
      $scope.output = data;
  });
  </code></pre>
  
  <p>Still get the dreaded: <code>{"error":"unsupported_grant_type"}</code></p>
  
  <p>So I do what no AngularJS developer should ever do, resorted to jQuery:</p>
  
  <pre><code>var data = $('#regForm').serialize() + "&amp;grant_type=password";
  $.post('/token', data).always(showResponse);
  
  function showResponse(object) {
      $scope.output = JSON.stringify(object, null, 4);
      $scope.$apply();
  };
  </code></pre>
  
  <p>Which works like a champ... so my question is: how do we replicate the jQuery <code>$.post()</code> call above using AngularJS <code>$http()</code> so we can grab an access token from the OWIN middleware based /token endpoint in ASP.Net Web API 2?</p>