简体   繁体   English

Flutter - 如何在 flutter 中自动刷新令牌

[英]Flutter - How to Auto Refresh token in flutter

What can be the best approach to auto refresh token in flutter? flutter 中自动刷新令牌的最佳方法是什么? I found this solution but is there any better approach than this?我找到了这个解决方案,但还有比这更好的方法吗?

This depend on where you're requesting your token from.这取决于您从哪里请求令牌。 If you're using firebase for example, firebase will handle this for you with it's auth package.例如,如果您使用 firebase,firebase 将使用它的身份验证 package 为您处理此问题。 If you're using your own API, apart from the solution you mentioned, you could also store your token with it's expire date with a package such as SecureStorage and perform a check if the token will almost expire and in that case request a new one.如果您使用自己的 API,除了您提到的解决方案之外,您还可以使用 package(例如 SecureStorage)存储您的令牌及其过期日期,并检查令牌是否即将过期,在这种情况下请求一个新的.

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

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