mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 03:46:00 +01:00
Enforce minimum token refresh rate
This commit is contained in:
@@ -62,14 +62,18 @@ public class GmailState {
|
||||
|
||||
void refresh(@NonNull Context context, @NonNull String user, boolean expire, long keep_alive)
|
||||
throws AuthenticatorException, OperationCanceledException, IOException {
|
||||
long now = new Date().getTime();
|
||||
Long expiration = getAccessTokenExpirationTime();
|
||||
if (expiration != null && expiration - keep_alive < new Date().getTime()) {
|
||||
if (expiration != null && expiration - keep_alive < now) {
|
||||
EntityLog.log(context, "Force invalidation" +
|
||||
" expiration=" + new Date(expiration) +
|
||||
" keep-alive=" + (keep_alive / 60 / 1000) + "m");
|
||||
expire = true;
|
||||
}
|
||||
|
||||
if (expiration != null && expiration - ServiceAuthenticator.MIN_EXPIRE_INTERVAL > now)
|
||||
expire = false;
|
||||
|
||||
if (expire)
|
||||
try {
|
||||
if (token != null) {
|
||||
|
||||
Reference in New Issue
Block a user