I am getting 401 error while sending post request using the angular code, when I inspected network request I found out that the headers are not being sent along the post request, please see the image:
auth.service.ts
login(username: string, password: string) {
let httpHeaders = new HttpHeaders({
'Authorization': 'Basic bXktdHJ1c3RlZC1jbGllbnQ6c2VjcmV0',
'Content-Type': 'application/json'
});
let options = {
headers: httpHeaders
};
this.http.post(
'http://localhost:8080/SpringSecurityOAuth2Example/oauth/token?grant_type=password&username=bill&password=abc123',
null,
options
).subscribe(res => {
console.log(res);
},
err => {
console.log(err);
}
);
}
Request missing headers
Although CORS is enabled on my server, so doesn't seem to CORS issue