-1
我正在使用Angular和.Net Web API 2後端進行身份驗證。我的註冊路線和其他資源正在運行,但登錄/令牌不是。Angular和Asp.net Web Api 2令牌
在角我的代碼如下所示:
credentials.grant_type = "password";
credentials.userName = "[email protected]";
credentials.password = "asdfasdf";
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlenconded' });
let options = new RequestOptions({ headers: headers });
return this.http.post('http://localhost:58352/Token', credentials, options).map((response: Response) => {
return response.json();
});
不過,我得到了響應:
{"error":"unsupported_grant_type"}
在Angular.js(或Angular 1)中我使用了transformRequest來使它工作。