title: Accessing Django server from AngularJs App: Easy authentication solution?
body: <p>I've been looking everywhere but can't seem to find an answer that has been helpful.</p>
  
  <p>I have written an angular app that is trying to pull data from a django RESTful backend that was written by my company. I have a username and password, but I'm not sure how to write the get request to provide the authentication credentials to the backend. I'm also confused about what exactly I'm supposed to provide in the header.</p>
  
  <p>Eventually, we will be communicating using nginx.</p>
  
  <p><strong>What I want</strong></p>
  
  <p>I'm looking for a fix to write in the angular app itself. I'm trying to write the angular app as separate as possible from the django backend. I have already enabled cross origin resource sharing.</p>
  
  <p>This will be a band aid fix just to display data from the backend. It does not need to be permanent by any means.</p>
  
  <p>So far I have tried:</p>
  
  <pre><code>app.factory('mySamples', ['$http', function($http) {
      return $http.get('website/api/foo', {
      headers: {'username':"foo", 'password': 'bar'}
    }).success(function(data) {
      return data;
    }).error(function(err) {
      return err;
    }); 
  };
  
  app.factory('mySamples', ['$http', function($http) {
      return $http({method: 'GET', url: 'website/api/samples/', headers: {
          'user': 'foo', 'auth':'bar'}
      });
  };
  </code></pre>
  
  <p>The second factory I wrote returns METHOD: OPTIONS in the networks inspector under returned header. Does anybody have a quick fix just to get data from my api? </p>
  
  <p>EDIT: My django backend doesn't support basic authentication, only session based. How would I edit my get request?</p>