I need to send a post request to a Spring Boot OAuth 2 Authorization Server to aquire the JWT token ? Using Postman I got the token and the Auth Server is working OK. But With Angular I am having a hard time figuring out the correct post request format?
This is the current method I'm using.
login() {
const url = 'http://localhost:9090/oauth/token';
const data = {
'grant_type': 'password',
'username': 'username',
'password': 'password'
};
const reqH = new HttpHeaders({
'Content-Type': 'application/x-www-urlencoded',
'Authorization': 'Basic ' + btoa('client-id' + ':' + 'secret'),
'grant_type': 'password',
'username': 'administrator%40divinedragon.com',
'password': 'password'
});
return this.http.post('http://localhost:9090/oauth/token', data, {
headers: reqH
});
}
when using this method I get the following error.
HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: "OK", url: "http://localhost:9090/oauth/token", ok: false, …},
error: {error: "invalid_request", error_description: "Missing grant type"}
Help is greatly appreciated !