Angular 2 sending header for authorization
<p>I am trying to get data from API that has oAuth authentication. 
What I am doing is sending the auth request from server1 (where my Angular app is) to server2 and I get the access token. Then I put the token in the JS variable and I am trying to access an API endpoint. </p>

<p>My js code looks like this:</p>

<pre><code>let headers = new Headers({ 'Authorization': "Bearer " + oAuthAccessToken });
let options = new RequestOptions({ headers: headers });
let url = "http://example.com/api/getSomething"
this.http.post(url, body, options)
    .subscribe( res =&gt; {
         console.log(res.json())
});
</code></pre>

<p>The problem is that I am always getting "401 Unathorized". When I inspect the request in the Network tab of Chrome Dev Tools I see two strange things - first the request method is OPTIONS not POST and the header Authorization is missing. </p>

<p>Any idea what I might be doing wrong ? Why is the header not set ?</p>

<p>Edit: </p>

<p>The problem was that Angular sends OPTIONS request before the POST and my app firewall was expecting Authorization header to be always present. This header is not present in the OPTIONS request so I was getting Unauthorized. I changed my server app to send proper headers on OPTIONS request and now everything is fine. </p>

<p>Thanks for the help.</p>