I'm trying to implement token authorization for Angular5 client and WebApi server application. I have managed to create WebApi part of the project in question and when I try to get the token via "POSTMAN" I get a good response:
Postman request and server answer
I'm trying to achieve the same with Angular5. This is my call from angular:
login(user: string, pass: string) {
let params = new HttpParams()
.append('grant_type', 'password')
.append('username', user)
.append('password', pass);
let headers = new HttpHeaders()
.set('Content-Type', 'application/x-www-form-urlencoded');
return this._http.post<boolean>('auth', params, { headers: headers });
}
When I run this, I'm keep getting "bad request" from server.Chrome response
If anyone has any idea, I would appreciate help. Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…