Most mobile apps use token-based authentication as a security technique to authenticates the users who attempt to log in to a server through the app.
Every user token has an expiration period(this is defined by the backend auth system), therefore the user cannot access the server with an expired token.
In this talk, I share how to use WorkManager to handle periodic background tasks, in this case, token refresh.
WorkManager is an Android library that runs deferrable background work when the work’s constraints are satisfied.