无法获取身份验证令牌

Unable to get authentication token

我正在尝试使用以下代码获取身份验证令牌,但我没有得到任何令牌。但是,我在邮递员那里得到了令牌。

fetchPeople() { 
    //return this.http.post('http://169.38.82.132:94/token',data,{ headers: this.headers }); 
    let url = "http://169.38.82.132:94/token";
    var headers = new HttpHeaders();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    headers.append('Accept', 'application/json');
    let urlSearchParams = new URLSearchParams();
    urlSearchParams.set('grant_type', 'password');
urlSearchParams.set('username', 'user');
urlSearchParams.set('password', 'user');
//let body = urlSearchParams.toString();
const data = 'grant_type=password';
return this.http.post( url, data,
  {headers: new HttpHeaders({
    'Accept': 'application/json',
    'Content-Type': 'application/x-www-form-urlencoded'
  })}  
  )
  };  
}
console.log(data);

我是否遗漏了任何逻辑设置。请指导我获取身份验证令牌。在控制台中得到

grant_type=password&username=user&password=user
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Live Reloading enabled.
POST http://169.38.82.132:94/token 400 (Bad Request)
fetchPeople() { 
    //return this.http.post('http://169.38.82.132:94/token',data,{ headers: this.headers }); 
    let url = "http://169.38.82.132:94/token";    
const data = 'grant_type=password&username=user&password=user';
return this.http.post( url, data,
  {headers: new HttpHeaders({
    'Accept': 'application/json',
    'Content-Type': 'application/x-www-form-urlencoded'
  })}  
  ).subscribe(resp => {
    console.log(resp);
})
  };  
}
console.log(data);

http post 正在返回一个 observable,因此您可以订阅并处理您的响应