0

What can be the best approach to auto refresh token in flutter? I found this solution but is there any better approach than this?

Ranjit Shrestha
  • 622
  • 6
  • 24

1 Answers1

0

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

Lorenzo
  • 103
  • 1
  • 6
  • where to check if the token is almost going to expire?, every time when I do a rest API call? I don't think it is good to call in every API call. if I check it when the user is opening the application then there may be token expiration during the user is using the application. – Ranjit Shrestha Apr 15 '21 at 02:57