简体   繁体   English

JWT 刷新令牌 Angular

[英]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.我不确定这是不是正确的论坛。在我的 angular 应用程序中,我想实现刷新令牌场景。 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.只有当我们从服务器收到 401 错误并调用 api 并获取新的令牌集时,我们才应该刷新令牌。
  2. we should set a timer in angular application that refreshes the token after certain time.我们应该在 angular 应用程序中设置一个计时器,在一定时间后刷新令牌。 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这是一个建议,它现在在 app.comp.ts 中保存带有过期日期的令牌,如果它的过期日期与当前日期匹配,则在其他情况下刷新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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