title: Authorization for window.location.href call in angular js
body: <p>I am working on a Web application. I have two seperate projects for UI and APIs. The apis require authentication for accessing. I wrote a common code to pass the token for each api call. </p>
  
  <pre><code>    App.config(function ($httpProvider) {
  $httpProvider.interceptors.push('authInterceptorService');    
  });
  </code></pre>
  
  <p>This is my authInterceptorService factory code.</p>
  
  <pre><code>    var localStorageLocation = ngAuthSettings.localStorageLocation;
  
          var authInterceptorServiceFactory = {};
  
          var _request = function (config) {
  
              config.headers = config.headers || {};
  
              var authData = localStorageService.get(localStorageLocation);
              if (authData) {
                      config.headers.Authorization = 'Bearer ' + authData.token;
              }
              return config;
          }
      authInterceptorServiceFactory.request = _request;
  </code></pre>
  
  <p>Now I have an API to download a pdf file. I am using 'window.location.href = uri'. But I am getting unauthorised exception. Now I want to know if there is a way to pass my token in the request. And is there any other way to access my file download url other than using window.location(I prefer using window.location but at this point I am desperate it to work in some way or other). </p>