Angular 2 Web Api发送身份验证令牌

时间:2017-05-13 01:14:28

标签: angular asp.net-web-api

有谁知道可能阻止我的令牌被我的API读取的内容, 是的,在我的api上启用了Cors,我可以从Fiddler调用我的终点(并成功地看到我的身份验证用户)。我有 确保IIS接受所有动词,并且我正在传递我的身份验证令牌:

public Post = (endpoint: string, filter?: Type): Observable<Type[]> => {
    let headers = new Headers();
    headers.append("Authorization",'Bearer ' + this._cookieService.get('access_token'));
    headers.append("Content-Type","application/json");
    let options = new RequestOptions({ headers: headers });
    debugger;

      return this._http.post(Config.API + endpoint, options)
        .map((response: Response) => <Type>response.json())
        .catch(this.handleError);
  }

我发送: enter image description here

然而,在我的服务器上,我得到: enter image description here

使用fiddler和auth令牌命中端点,如下所示: 授权=&gt;承载WiZJQv9TJHEixcdI4FS94PUWsQlwkslKBXKq_fBbeup66XA0OuhG9jkyHbJ1ONKykxEtNHf-WpETb5r4Vj_42GvBu2SPSM_rWhs_svwzBesa9ozpkgRBVm_BvNShiUDGlD4T5-X2s4PFC1ssxQ4a74qb8ZfASG8nd8OS1hGxwaYC5e0uBZWxPvHqGEicJVOJ6qd-ANb56wkwavCnt1PUr4BK0X6z1UWCAhSf8iZGC_w8wmDr7sVQqEkxdoRQPH8_PFVNivbq9qPO1kLDMrsDTchohLR1spET9IxHvWgrTwV8D5tNysj_ZH4vxp_yXjYoCyOvzvC-nU4poX8NUPIh2Z-3MgxjbTMGA35sn3TMZo1XvpFcdChXSQFHig8hzHqXjfj_K8czM3xaIgjx-RgzLVcl_A-I-7vGFY9TcmLBqC8-mQ4eTOqgW6j4cm9N5mfk6VmIlCOAWJu2k1cixwZHxwOsvdkbBQJP8bbnjUeYJ1k 结果为:enter image description here

我已经在这几个小时了,有人请给我指针吗? 谢谢, -Kevin

1 个答案:

答案 0 :(得分:1)

我发现了这个问题,我省略了帖子的正文。这是一个更正后的帖子:

return this._http.post(Config.API + endpoint, filter, options)
        .map((response: Response) => <Type>response.json())
        .catch(this.handleError);