I am making a application in Flutter.
I have a access token coming from an API which I save in shared preferences for session management and authentication.
But here the catch is that this token expires every 1 hour so I need to clear the shared preferences every 1 hour ..
Package used – shared_preferences
So, How do I do that??
3
Answers
I suppose you can handle this scenario better with other approaches, however, if you want to invalidate your token locally based on a validation time you can do this:
You can clear using this. But it has some limitation regarding background case.
Here’s my solution. I’ve used one feature-rich package, which helps us to decode the JWT Token. Decoding means extracting the information.
I’ve used: jwt_decoder