I followed the ideas in this post. I just made a few changes, like using ASP.net core and Angular 2 front running on the same port using jwt bearer token authentication.
I'm using ADAL.js to authenticate Azure AD and this process seems to work fine. I'm getting my token from Azure AD and its getting save in localstorage.
When I use the token which is getting save in local storage to call my API I'm getting 401
Call from Angular 2 to WebApi both residing on same port.
var token = localStorage["adal.access.token.keye1b88e53-810a-474d-93af-bb98c956d01e"];
console.log(token);
let headers = new Headers({
'Authorization': 'Bearer ' + token, 'Accept': 'application/json; odata.metadata=minimal'
});
let options = new RequestOptions({ headers: headers });
return this.http.get('https://localhost:44375/api/values', options)
.map((response: Response) => response.json()).subscribe((val) => {
console.log(val);});
This call comes back with a 401 with this message
Bearer error="invalid_token", error_description="The token is expired"
Any ideas are appreciated. Thanks!