angular-http-interceptors

Unknown Reason for JWT Tokens invalidation

元气小坏坏 提交于 2019-12-11 12:54:41
问题 I'm facing very weird problem with my laravel-Angular application. I'm using Tymon JWT to refresh token on my every request. I'm using Satellizer library to handle these JWT-Tokens, however, Satellizer doesn't seem to have a response interceptor to capture the new token. Hence I wrote my own Interceptor to do so. .factory('ResponseHttpInterceptor', function ($window) { return { response: function (response) { if (response.headers('Authorization') != null) { $window.localStorage.removeItem(

Circular dependency while pushing http interceptor

Deadly 提交于 2019-12-11 04:01:22
问题 I am using http Interceptor to intercept each http request in my application. But I am getting Circular dependency found: $http <- APIInterceptor <- $http <- $templateRequest <- $compile here is my Service code: mPosServices.factory('mosServiceFactory', function ($http, $rootScope, $cookies, $q) { return{ refresh_token: function () { var refreshToken = $http({ method: "get", url: "myservice/oauth/token?grant_type=refresh_token&client_id=restapp&client_secret=restapp&refresh_token=" + $cookies

Ionic 3 + HttpClientModule and token from storage

你离开我真会死。 提交于 2019-12-10 16:51:48
问题 I have build an interceptor for making HTTP requests to a PHP backend. This backend gives an JWT token to the app and I save this in the Ionic Storage. But I want to get that token from Storage and add it as an header to the HTTP request. Below is my interceptor with and hardcoded token. This works and I get a response from the backend. See update @ bottom of this post http-interceptor.ts import { HttpInterceptor, HttpRequest } from '@angular/common/http/'; import {HttpEvent, HttpHandler}

Angular 5 / HttpInterceptor / Detect (cancelled) xhr

↘锁芯ラ 提交于 2019-12-10 12:49:24
问题 In my angular app I'm seeing chrome (cancel) api calls that fire off too rapidly. I also have an HttpInterceptor that triggers a loading indicator with every HttpClient request after 500ms if the request has not completed. However, on the requests that get (cancelled) there does not seem to be any new event to subsequently hide my loading indicator. Is there a way to detect 'cancelled' requests in the HttpInterceptor so I can hide my loading indicator again? export class GlobalHttpInterceptor

Overload request headers and params with HttpClient get

可紊 提交于 2019-12-10 11:04:08
问题 In HttpClientModule, is there a method to pass headers and params to get request. import { HttpHeaders, HttpParams, HttpClient } from @angular/common/http'; const headers = { headers: new HttpHeaders({}) } let params = new HttpParams({ }); get(url, {params}) // http client get with params get(url, {headers}); //http client get with headers I want something like requestoptions to hold both or a syntax to do httpClient get sending request headers and params. Currently building complete url with

Right way to disable/remove http interceptors in Angular?

喜夏-厌秋 提交于 2019-12-10 01:26:58
问题 I followed this post to implement a similar ajax loader image on a project: Implementing loading spinner using httpInterceptor and AngularJS 1.1.5 My implementation has a few differences: I use $rootScope to emit and not broadcast and I also use $rootScope on the directive to handle the event. Because of a particularity of the project, I have to unbind the directive $rootScope.$on listeners right after the first event being fired (either for show or hide), inside the event handler. I only

Angular 4 HttpInterceptor refresh token

允我心安 提交于 2019-12-08 10:10:22
问题 I have HttpInterceptor : import {HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http'; import {AuthService} from '../service/auth.service'; import {Observable} from 'rxjs/Observable'; import {Injectable} from '@angular/core'; import {Router} from '@angular/router'; @Injectable() export class AuthInterceptor implements HttpInterceptor { constructor(private authService: AuthService, private router: Router) { } intercept(request: HttpRequest<any>,

Shared AngularJS $http interceptors

回眸只為那壹抹淺笑 提交于 2019-12-07 12:04:44
问题 I am wondering if Angular.js $http interceptors are shared thoughout the whole application. Let's assume I have a myDependentApp module, shared between many apps. That module has some interceptor configured to control the $http requests/responses. I include that module by declaring it in application bootstrap: angular.module('myApp', ['myDependentApp']); And I have application template: <html ng-app="myApp"> Are myDependentApp 's interceptors going to be active in myApp ? Thanks for help. 回答1

Angular HttpInterceptor not changing header

醉酒当歌 提交于 2019-12-07 11:12:37
问题 I wrote an angular (4.3.6) HttpInterceptor to add some header fields, but the header doesn't get updated if I inspect them in the debugger. Any idea? import {Injectable} from '@angular/core'; import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest} from '@angular/common/http'; import {Observable} from 'rxjs/Observable'; @Injectable() export class AuthInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { console.log(

Request Header is not updated successfully from interceptor angular 2/4 (401 handling)

筅森魡賤 提交于 2019-12-07 04:48:25
问题 I am working with Http interceptor and trying to retry the failed request to handle 401 error . I am trying to set a new header to update the request but it's not working. I noticed that My header is not being set with the request instead it's going to the lazyUpdates inside headers. Can anyone provide me the any idea why it's happening. After checking my networks I found that with the retry request old header is passed which is 'x-auth-token' and new headers are not sent. interceptor.ts