Check token expiration

This commit is contained in:
M66B 2022-07-21 14:45:47 +02:00
parent 549a6f1fcd
commit 3b82117c6a
1 changed files with 11 additions and 0 deletions

View File

@ -2241,6 +2241,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
throw new StoreClosedException(iservice.getStore(), "Unrecoverable", cause);
}
// Check token expiration
if (!account.isTransient(this)) {
Long expirationTime = iservice.getAccessTokenExpirationTime();
if (expirationTime != null && expirationTime < new Date().getTime()) {
EntityLog.log(this, EntityLog.Type.Debug, "Token" +
" expired=" + new Date(expirationTime) +
" user=" + account.provider + ":" + account.user);
throw new IllegalStateException(Log.TOKEN_REFRESH_REQUIRED);
}
}
// Sends store NOOP
if (EmailService.SEPARATE_STORE_CONNECTION) {
EntityLog.log(this, EntityLog.Type.Account, account,