如何从离子2中的ASP API获取令牌

时间:2017-03-12 17:08:30

标签: angular asp.net-web-api ionic2

我创建了一个ASP API,并在创建时使用了单个用户帐户的选项。我已经注册了一个奇妙的用户,甚至检查它们是否存在于数据库中。当我尝试从API为注册用户请求授权令牌时出现问题。

我使用postman工作,API响应很好。

以下是调用API的代码。

selectCatComboBox.removeAllItems();

以下是控制台上显示的错误消息。

let body = "grant_type=password" + "&userName=" + credentials.email + "&password=" + credentials.password;
  let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
  let options = new RequestOptions({ headers: headers });
  return this.http.post('http://localhost:59179/token', body, options).subscribe(response => {
    console.log(response);
  });

我做错了吗?我错过了什么吗?任何人都可以提供帮助我完成这项工作的任何事情都将是一个很大的帮助,非常感谢。

0 个答案:

没有答案