title: AngularJS: How to send auth token with $resource requests?
body: <p>I want to send an auth token when requesting a resource from my API.</p>
  
  <p>I did implement a service using $resource:</p>
  
  <pre><code>factory('Todo', ['$resource', function($resource) {
   return $resource('http://localhost:port/todos.json', {port:":3001"} , {
     query: {method: 'GET', isArray: true}
   });
  }])
  </code></pre>
  
  <p>And I have a service that stores the auth token:</p>
  
  <pre><code>factory('TokenHandler', function() {
    var tokenHandler = {};
    var token = "none";
  
    tokenHandler.set = function( newToken ) {
      token = newToken;
    };
    tokenHandler.get = function() {
      return token;
    };
  
    return tokenHandler;
  });
  </code></pre>
  
  <p>I would like to send the token from <code>tokenHandler.get</code> with every request send via the <code>Todo</code> service. I was able to send it by putting it into the call of a specific action. For example this works:</p>
  
  <pre><code>Todo.query( {access_token : tokenHandler.get()} );
  </code></pre>
  
  <p>But I would prefer to define the access_token as a parameter in the <code>Todo</code> service, as it has to be sent with every call. And to improve DRY.
  But everything in the factory is executed only once, so the access_token would have to be available before defining the factory and it cant change afterwards.</p>
  
  <p><strong>Is there a way to put a dynamically updated request parameter in the service?</strong></p>