title: AngularJS convert $http to $resource
body: <p>I am new to angular so this is probably a simple question.
  I have a service that looks like this:</p>
  
  <pre><code>.factory('MoltinApi', ['$resource', '$http', 'moltin_options', 'moltin_auth', function ($resource, $http, options, authData) {
      var api = $resource(options.url + options.version + '/:path', {
          path: '@path'
      });
  
      var authenticate = function () {
          if (!options.publicKey)
              return;
  
          var request = {
              method: 'POST',
              url: options.url + 'oauth/access_token',
              headers: {
                  'Content-Type': 'application/x-www-form-urlencoded'
              },
              data: "grant_type=implicit&amp;client_id=" + options.publicKey
          };
  
          $http(request).success(function (response) {
              authData = response;
  
              console.log(response);
          });
      };
  
      authenticate();
  
      return api;
  }])
  </code></pre>
  
  <p>as you can see, there is an <strong>authenticate</strong> method which is called when the class is instantiated. What I would like to do, is convert it from being an $http call and use $resource instead (because I am returning a $resource and it just seems messy to be using both $http and $resource).</p>
  
  <p>Does anyone know how I can do that?</p>