1

How to handle access token expiration in angular application that uses oidc code flow?

I set the automaticSilentRenew to true in oidc client settings, which is triggering a call to the token endpoint and getting new access token, then I listen to the addAccessTokenExpiring event and set the new user information.

Is there a different way for handling expired tokens when using authorization code flow? can't get this to work properly!

//Note: this.user object contains the access token that I use when I request a protected api

  this.mgr.events.addAccessTokenExpiring(() => {   
    console.log("token expiring...");
    this.mgr.getUser().then(user => {
      this.user = user;
    });
  });

I expect that the http request I made to the protected api will be using the new access token but it ends up using the expired one and receiving 401 on the client side...

tlr_k
  • 11
  • 2
  • Can you share your silent renew call back code ? Look at this and see if it helps, https://stackoverflow.com/questions/50416649/no-user-in-signinsilentcallback-using-identityserver-and-oidc-client-of-javascri/50442976#50442976 – Sohan Sep 16 '19 at 06:06
  • Thanks @Sohan for your help, using the addUserLoaded event seems to have solved my problem. – tlr_k Sep 17 '19 at 15:41

0 Answers0