angular2-jwt

Generic http error handling in Angular

坚强是说给别人听的谎言 提交于 2019-12-01 09:58:26
问题 angular2-jwt provides an AuthHttp wrapper for the native Angular http class that automatically includes the http authorization header with each request. In my services I am usually calling a backend api like this getThings(): Observable<Thing[]> { return this.http.get(environment.apiEndpoint + '/things') .map(res => res.json().data) .catch(res => this.handleError(res)); } with an error handler like private handleError(error: Response | any) { let errMsg: string; if (error instanceof Response)

IdentityServer BearerAuthentication from WebApi Middleware using angular2-jwt

怎甘沉沦 提交于 2019-11-29 17:51:29
after updating my project to angular 2 final i had a problem getting WebApi2 authoriaztion to work with IdentityServer3 and angular2-jwt. Before everything worked fine when in angular2-jwt configuration the headername was empty and the token-getter-method returned simply the token. After updating an empty headername caused an javascript-error: EXCEPTION: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name. So first i had to provide a headername, in my root-module angular2-jwt config looked like this: provideAuth({ headerName: 'BearerToken',

IdentityServer BearerAuthentication from WebApi Middleware using angular2-jwt

淺唱寂寞╮ 提交于 2019-11-28 13:10:50
问题 after updating my project to angular 2 final i had a problem getting WebApi2 authoriaztion to work with IdentityServer3 and angular2-jwt. Before everything worked fine when in angular2-jwt configuration the headername was empty and the token-getter-method returned simply the token. After updating an empty headername caused an javascript-error: EXCEPTION: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name. 回答1: So first i had to provide a