Based on your code user cannot logout untill he hit logout button right ..but if we want when user actively working in this case I need refresh token if user not working and token expired then I need he should logout and relogin ...please suggest me
I had issues with token data and changed the property names at Savetoken function jwtToken to JWTToken, and refreshToken to RefreshToken. jwtToken and refreshToken were undefined.
im getting list data by using intercepotrs refresh token method,(after expiration the data is getting) in console, it showing the request is error with 401 status. why it is giving in console, when it is working . is it a bug ??
Hello! Thx for this great example! But.... if you wanna receive the refresh token and the server response 401, too (is expired, too as example) nothing happened. The Interceptor hangs and the error will not be handled.
cant we avoid printing the 401 unauthroized in console, we are calling handlerefreshing token it is working good, but when the token is expired it will check status 401 and call refresh method. when token is expired, it is showing 401 in console
Switchmap is one of rxjs operators for access observable inside the observanle for more details refer this link ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FVgaacYNoy0.html
1,Can you share the error message? 2, when you are facing issue while running (or) after deployment? 3,Possible reason when 2 services depending on each other then this will show error. Solving this error need to create separate service
Hello, I copied your code as you have it and I am using Angular 14. On the refresh I am receiving this error: pipe is not a function at this line of code: return authservice.GenerateRefreshToken().pipe(. Did something change between Angular 13 and 14? Here is my code: handleRefrehToken(request: HttpRequest, next: HttpHandler) { let authRequest = request; return this.authService.GetRefreshToken().pipe( switchMap((data: any) => { this.authService.SaveTokens(data); //authRequest = this.AddTokenheader(request); return next.handle(this.AddTokenheader(request)); }), catchError(errordata =>{ console.log('logout') this.store.dispatch(logoutAction()); return throwError(()=>errordata); }) ); I have Angular version 14.2.3 and "typescript": "~4.8.3" thank you