Here's my angular method
getGiftList(url: string){
let q = this.baseUrl + url;
let headers = new HttpHeaders();
let authToken = 'Bearer ' + this.authService.currentUser.token;
console.log(q); //Log the url ...
console.log(authToken); Log the token ...
headers.set('Authorization', authToken)
return this.http.get(q, {
observe: 'response'
,headers: headers
})
}
And this is the Asp.net core method
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class GiftController : Controller
{
[HttpGet("api/giftsByGiver/{email}")]
public IActionResult getGiftBasicRecordsByGiver(string email, int cpg = 1)
{
//
}
}
When I make a request from my angular code, I get a 401 error. However, when I copy/peste the same values that I logged to Postman and run, I'm getting the right result.
Am I missing something?
Thanks for helping
origin, method, and header.