Trying to generate Oauth2 token I have used Spring Boot Oauth2 and Angular 5
In postman and curl I'm able to generate the token by passing the appropriate values and with the same parameter it is not working in the Angular POST
Error
OPTIONS http://localhost:9999/auth-service/oauth/token 401 () Failed to load http://localhost:9999/auth-service/oauth/token: Response for preflight has invalid HTTP status code 401.
Angular Code
login2(credentials){
let headers = new Headers();
var creds = 'client_id=finance-service&client_secret=finance&grant_type=client_credentials&socpe=server';
headers.append('Content-Type', 'application/x-www-form-urlencoded');
headers.append("Authorization", "Basic " + btoa("finance-service:finance"));
console.log(btoa("finance-service:finance"))
return new Promise((resolve) =>{
this.http.post(SMSGlobal.authPath, creds, {headers : headers})
.subscribe((data) =>{
console.log(data.json());
},
(error) =>{
console.log(error);
})
})
}
I've configured CORS in Backend as well