简体   繁体   中英

JWT Refresh token Angular

I am not sure this is the right forum for this.In my angular application, I want to implement refresh token scenario. but we are thinking of two different approaches.

  1. we should refresh the token only when we received 401 error from the server and make a call to the api and get the new set of tokens.
  2. we should set a timer in angular application that refreshes the token after certain time. I am not sure which path we should take? I have tried to analyze it I feel we need to take approach one. but I am reaching out to experts to understand the advantages of one over the other?

Here is a suggestion for it save token with the expire date now in app.comp.ts match current date with expire date if its passes expire date then refresh in other case refresh token

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM