devlogquedulaapi
Devlog #11: Token refresh strategy
TikTok API tokens have a limited lifetime. If a token expires at the moment of publication, the task fails with an authorization error. This is a bad user experience.
Our strategy: refresh the token proactively, not reactively. A background process periodically checks token expiration and refreshes those with less than a certain time remaining.
The refresh token also expires, but with a longer lifetime. If the refresh token has expired — the only option is to ask the user to re-authorize. We notify about this in advance, when it hasn't expired yet but will soon.
Proactive refresh = fewer failures at the worst possible moment.