Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XOAUTH2 Authentication Failed but not required! #442

Closed
tommasop opened this issue Mar 14, 2017 · 7 comments
Closed

XOAUTH2 Authentication Failed but not required! #442

tommasop opened this issue Mar 14, 2017 · 7 comments

Comments

@tommasop
Copy link

General informations

  • system/distribution (with version): OSX 10.11.6
  • offlineimap version (offlineimap -V): offlineimap v7.0.14, imaplib2 v2.57 (bundled), Python v2.7.11
  • Python version: 2.7.11
  • server name or domain: G Suite
  • CLI options: None

Configuration file offlineimaprc

[general]
accounts = A, B
ui = ttyui
pythonfile=~/bin/offlineimap-helpers.py

[Account A]
localrepository = LocalA
remoterepository = RemoteA

[Account B]  <-- G Suite
localrepository = LocalB
remoterepository = RemoteB

[Repository LocalA]
type = Maildir
localfolders = ~/Mail/A

[Repository RemoteA]
type = IMAP
createfolders = False
remotehost = 
remoteuser = 
remotepasseval = get_pass("A")
ssl=true
sslcacertfile = /usr/local/etc/openssl/cert.pem
expunge = no
folderfilter = lambda foldername: foldername not in ['INBOX.Trash']
nametrans = lambda folder: re.sub('^INBOX\.', '', re.sub(' +', '_', folder))
maxconnections = 3

[Repository LocalB]
type = Maildir
localfolders = ~/Mail/B

[Repository RemoteB]
type = IMAP
createfolders = False
auth_mechanisms = PLAIN,LOGIN   <-- WITHOUT THIS LINE GIVES THE ERROR
remotehost = imap.gmail.com
remoteuser = 
remotepasseval = get_pass("B")
ssl=true
sslcacertfile = /usr/local/etc/openssl/cert.pem
expunge = no
folderfilter = lambda foldername: foldername not in ['INBOX.Trash']
nametrans = lambda folder: re.sub('^INBOX\.', '', re.sub(' +', '_', folder))
folderfilter = lambda foldername: foldername not in ['[Gmail]/Spam','[Gmail]/Trash']
maxconnections = 3

pythonfile (if any)

#! /usr/bin/env python2
from subprocess import check_output

def get_pass(account):
        return check_output("gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.msmtp-" + account + ".gpg", shell=True).strip("\n")

Logs, error

Account sync B:
 *** Processing account B
 Establishing connection to imap.gmail.com:993 (RemoteB)
 XOAUTH2 authentication failed: AUTHENTICATE command error: BAD ['Client aborted AUTHENTICATE command. s4mb245366598wrc']. Data: IPNF2 AUTHENTICATE XOAUTH2

Steps to reproduce the error

  • launch offlineimap
@nicolas33 nicolas33 added the bug label Mar 14, 2017
@nicolas33 nicolas33 self-assigned this Mar 14, 2017
nicolas33 added a commit to nicolas33/offlineimap that referenced this issue Mar 15, 2017
Checking if we have to run this authentication method once it's already passed
to imaplib2 is too late. Make the checks at correct time, before we try the
authentication method. IOW, before we call

  imapobj.authenticate('XOAUTH2', self.__xoauth2handler)

Github-ref: OfflineIMAP#442
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
@nicolas33
Copy link
Member

Does the above patch/version fix your issue?

@nicolas33
Copy link
Member

It's possible to install offlineimap as a user: remove the currently installed offlineimap and download the zip (or git clone the repository). Then ./offlineimap.py [options].

@tommasop
Copy link
Author

tommasop commented Mar 22, 2017 via email

@nicolas33
Copy link
Member

,-)

I'm pretty sure you've noticed the correct version to check is this one.

I'd say that downloading the zip is better to be sure the version is correct. Otherwise, git users have to make sure they've "checkout" the correct branch.

@nicolas33
Copy link
Member

Gentle up!

@klemens
Copy link

klemens commented Apr 27, 2017

I had the same problem and the patch applied on top of version 7.1.0 seems to fix it (I didn't have any XOAUTH2-errors since then).

@nicolas33
Copy link
Member

Thank you much @klemens ! Patch applied. :-)

nicolas33 added a commit that referenced this issue Apr 27, 2017
Checking if we have to run this authentication method once it's already passed
to imaplib2 is too late. Make the checks at correct time, before we try the
authentication method. IOW, before we call

  imapobj.authenticate('XOAUTH2', self.__xoauth2handler)

Github-ref: #442
Tested-by: Klemens Schölhorn <klemens@schoelhorn.eu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants