XOAUTH2: don't try this authentication method when not configured
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: https://github.com/OfflineIMAP/offlineimap/issues/442 Tested-by: Klemens Schölhorn <klemens@schoelhorn.eu> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
4ac44071b6
commit
39b657194a
@ -221,10 +221,6 @@ class IMAPServer(object):
|
||||
return retval
|
||||
|
||||
def __xoauth2handler(self, response):
|
||||
if self.oauth2_refresh_token is None \
|
||||
and self.oauth2_access_token is None:
|
||||
return None
|
||||
|
||||
if self.oauth2_access_token is None:
|
||||
if self.oauth2_request_url is None:
|
||||
raise OfflineImapError("No remote oauth2_request_url for "
|
||||
@ -353,6 +349,10 @@ class IMAPServer(object):
|
||||
return True
|
||||
|
||||
def __authn_xoauth2(self, imapobj):
|
||||
if self.oauth2_refresh_token is None \
|
||||
and self.oauth2_access_token is None:
|
||||
return False
|
||||
|
||||
imapobj.authenticate('XOAUTH2', self.__xoauth2handler)
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user