Angular Authentication part - 2 (Handling refresh token + Http Interceptor + .NET Core API) #28

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024

Комментарии • 31

  • @beautysingh2415
    @beautysingh2415 2 года назад +1

    Very nice and helpful can you explain how to handle cors error in production

  • @janoshollosi9570
    @janoshollosi9570 11 месяцев назад

    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.

    • @NihiraTechiees
      @NihiraTechiees  11 месяцев назад

      It's case sensitive so check what response you received from api.... Change it accordingly

  • @sushilAmbedkarwadi
    @sushilAmbedkarwadi 8 месяцев назад

    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

    • @NihiraTechiees
      @NihiraTechiees  8 месяцев назад

      In interceptor i added calling refresh token logic... Then you can directly do log out also you can give some alert like current session expired

    • @sushilAmbedkarwadi
      @sushilAmbedkarwadi 8 месяцев назад

      @@NihiraTechiees thank you sir

  • @PlusFlo
    @PlusFlo 2 года назад

    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.

    • @NihiraTechiees
      @NihiraTechiees  2 года назад

      For error handling follow this video ruclips.net/video/aiknsMjF1n0/видео.html

  • @techbuzz3869
    @techbuzz3869 2 года назад

    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

    • @NihiraTechiees
      @NihiraTechiees  2 года назад

      Please share the code snippets to my mail

    • @WilbertQuijano
      @WilbertQuijano Год назад

      Same here, if you can share the solution please

  • @techbuzz3869
    @techbuzz3869 2 года назад

    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
    ??

    • @NihiraTechiees
      @NihiraTechiees  2 года назад

      Did you missed any step. Please verify it

  • @WilbertQuijano
    @WilbertQuijano Год назад

    is it normal that in developers tool, you will see 401 error, even you have intercepted 401?

    • @NihiraTechiees
      @NihiraTechiees  Год назад

      May be previous exception not cleared

    • @WilbertQuijano
      @WilbertQuijano Год назад

      Can you show in the video the dev tools is not logging any 401 in console? Tyia

  • @EREN11997
    @EREN11997 2 года назад

    What is the use of switchMap()?

    • @NihiraTechiees
      @NihiraTechiees  2 года назад

      Switchmap is one of rxjs operators for access observable inside the observanle for more details refer this link ruclips.net/video/FVgaacYNoy0/видео.html

  • @raulrothschild
    @raulrothschild 2 года назад

    In getting Circular dependency in DI error ):

    • @NihiraTechiees
      @NihiraTechiees  2 года назад

      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

  • @adekolaolawale3543
    @adekolaolawale3543 3 месяца назад

    This guy really needs to work on his accent and explanation, he is really bad explaining concepts in a comprehensible manner

    • @NihiraTechiees
      @NihiraTechiees  3 месяца назад

      I happy to have freelancer like you for doing free quality check....good job brother 👍

  • @kevincordell9539
    @kevincordell9539 Год назад

    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