Refresh OAUTH tokens

Refs #17
This commit is contained in:
M66B
2018-08-27 16:19:56 +00:00
parent 4d7c3e9c88
commit 846a39eb78
43 changed files with 140 additions and 45 deletions

View File

@@ -391,6 +391,12 @@ public class ServiceSynchronize extends LifecycleService {
if (debug)
System.setProperty("mail.socket.debug", "true");
// Refresh token
if (account.auth_type == Helper.AUTH_TYPE_GMAIL) {
account.password = Helper.refreshToken(this, "com.google", account.user, account.password);
db.account().setAccountPassword(account.id, account.password);
}
Properties props = MessageHelper.getSessionProperties(account.auth_type);
final Session isession = Session.getInstance(props, null);
isession.setDebug(debug);
@@ -971,6 +977,12 @@ public class ServiceSynchronize extends LifecycleService {
return;
}
// Refresh token
if (ident.auth_type == Helper.AUTH_TYPE_GMAIL) {
ident.password = Helper.refreshToken(this, "com.google", ident.user, ident.password);
db.identity().setIdentityPassword(ident.id, ident.password);
}
// Create session
Properties props = MessageHelper.getSessionProperties(ident.auth_type);
final Session isession = Session.getInstance(props, null);