我正在尝试读取 401 响应的 www-authenticate 标头,以便我可以触发令牌刷新并将请求再次发送到 API。但是,我似乎无法从错误响应中读取标题。下面是角度代码。尝试刷新访问令牌的其他任何人都面临这个问题吗?
const headers = new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'bearer ' + this.accessToken
});
const httpCall = this.http.get<T>(getUrl, { headers: headers, observe : 'response'});
return httpCall
.pipe(
map(resp => {
console.log(resp);
return resp.body;
}),
catchError((err: HttpResponse<T>, resp) => {
console.log(err.headers.get('www-authenticate'));
console.error(err);
return of(null);
})
);
任何帮助都会很有用。谢谢。