mirror of https://github.com/M66B/FairEmail.git
Log token expiration
This commit is contained in:
parent
b0dd941d69
commit
21c8868189
|
@ -53,6 +53,13 @@ public class GmailState {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long getAccessTokenExpirationTime() {
|
||||||
|
if (token == null || acquired == 0)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return acquired + TOKEN_LIFETIME;
|
||||||
|
}
|
||||||
|
|
||||||
void refresh(@NonNull Context context, @NonNull String user, boolean expire) throws AuthenticatorException, OperationCanceledException, IOException {
|
void refresh(@NonNull Context context, @NonNull String user, boolean expire) throws AuthenticatorException, OperationCanceledException, IOException {
|
||||||
if (expire || acquired + TOKEN_LIFETIME < new Date().getTime())
|
if (expire || acquired + TOKEN_LIFETIME < new Date().getTime())
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.openid.appauth.NoClientAuthentication;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
|
@ -84,6 +85,9 @@ public class ServiceAuthenticator extends Authenticator {
|
||||||
if (auth == AUTH_TYPE_GMAIL) {
|
if (auth == AUTH_TYPE_GMAIL) {
|
||||||
GmailState authState = GmailState.jsonDeserialize(password);
|
GmailState authState = GmailState.jsonDeserialize(password);
|
||||||
authState.refresh(context, user, expire);
|
authState.refresh(context, user, expire);
|
||||||
|
Long expiration = authState.getAccessTokenExpirationTime();
|
||||||
|
if (expiration != null)
|
||||||
|
EntityLog.log(context, user + " token expiration=" + new Date(expiration));
|
||||||
|
|
||||||
String newPassword = authState.jsonSerializeString();
|
String newPassword = authState.jsonSerializeString();
|
||||||
if (!Objects.equals(password, newPassword)) {
|
if (!Objects.equals(password, newPassword)) {
|
||||||
|
@ -96,6 +100,9 @@ public class ServiceAuthenticator extends Authenticator {
|
||||||
} else if (auth == AUTH_TYPE_OAUTH) {
|
} else if (auth == AUTH_TYPE_OAUTH) {
|
||||||
AuthState authState = AuthState.jsonDeserialize(password);
|
AuthState authState = AuthState.jsonDeserialize(password);
|
||||||
OAuthRefresh(context, provider, authState);
|
OAuthRefresh(context, provider, authState);
|
||||||
|
Long expiration = authState.getAccessTokenExpirationTime();
|
||||||
|
if (expiration != null)
|
||||||
|
EntityLog.log(context, user + " token expiration=" + new Date(expiration));
|
||||||
|
|
||||||
String newPassword = authState.jsonSerializeString();
|
String newPassword = authState.jsonSerializeString();
|
||||||
if (!Objects.equals(password, newPassword)) {
|
if (!Objects.equals(password, newPassword)) {
|
||||||
|
|
Loading…
Reference in New Issue