offlineimap
offlineimap copied to clipboard
XOAUTH2 authentication failed
Using offlineimap 7.1.5, I fetch gmail emails via oauth2 token:
oauth2_client_id_eval = get_id_token_fromdict("gmail") oauth2_client_secret_eval = get_secret_token_fromdict("gmail") oauth2_refresh_token_eval = get_refresh_token_fromdict("gmail")
This work well at first, but after a while I get the following error messages: XOAUTH2 authentication failed: [AUTHENTICATIONFAILED] Invalid credentials
Restarting offlineimap the authentification works again.
Just before it starts failing, I see Attempting NOOP on dropped connection imap.gmail.com (typically because I am resuming from suspend to ram).
So it would seems like somehow xoauth2 token are not correctly refreshed when restarting a dropped connection?
Yep, the connection is no longer authenticated on gmail server side, due to the fact your computer suspended to RAM which caused it to drop the TCP network connection from your side to the Gmail imap server. The software needs a contributor to add code to detect this dropped network connection, and re-authenticate login.
Linked to #56 .
@DamienRobert
Try adding this setting socktimeout
into your .offlineimaprc
config file [general]
section:
[general]
socktimeout = 10
offlineimap fails for me after 1 hour of successful syncing with autorefresh=5, which I guess is related to:
$ offlineimap -d ALL -c gmail.rc
...
[imap]: xoauth2handler: response "{u'access_token': u'xxxxxxxxxxxx', u'token_type': u'Bearer', u'expires_in': 3600}"
...
Yep, the Gmail XOAUTH2
login expires after one hour @kucharskim .
We should probably upgrade the code so that it will detect the error that the login token has expired, get a new token, and continue.
@chris001: I already had 'socktimeout=90'. I'll try with socktimeout=10, but this is not a real fix, this just means we hope that the timeout will occur before the connection is resumed after a suspend so that offlineimap will reset the connection properly. (I understand this is hard to fix).
Thanks you all for your help.