From af640208e18e9f7997ba37587302605af0c95022 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Mon, 12 Oct 2015 07:37:39 +0200 Subject: [PATCH] make XOAUTH2 configuration option optional Signed-off-by: Nicolas Sebrecht --- offlineimap/repository/Gmail.py | 10 +++++----- offlineimap/repository/IMAP.py | 9 +++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/offlineimap/repository/Gmail.py b/offlineimap/repository/Gmail.py index 1e2069b..47ad744 100644 --- a/offlineimap/repository/Gmail.py +++ b/offlineimap/repository/Gmail.py @@ -56,12 +56,12 @@ class GmailRepository(IMAPRepository): Gmail implementation first checks for the usual IMAP settings and falls back to imap.gmail.com if not specified.""" - try: - return super(GmailRepository, self).getoauth2_request_url() - except OfflineImapError: - # nothing was configured, cache and return hardcoded one + + url = super(GmailRepository, self).getoauth2_request_url() + if url is None: + # Nothing was configured, cache and return hardcoded one. self._oauth2_request_url = GmailRepository.OAUTH2_URL - return self._oauth2_request_url + return self._oauth2_request_url def getport(self): return GmailRepository.PORT diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 414b918..fd2464f 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -259,7 +259,7 @@ class IMAPRepository(BaseRepository): return [f.strip().lower() for f in value.split(',') if f] def getoauth2_request_url(self): - if self._oauth2_request_url: # use cached value if possible + if self._oauth2_request_url: # Use cached value if possible. return self._oauth2_request_url oauth2_request_url = self.getconf('oauth2_request_url', None) @@ -267,11 +267,8 @@ class IMAPRepository(BaseRepository): self._oauth2_request_url = oauth2_request_url return self._oauth2_request_url - # no success - raise OfflineImapError("No remote oauth2_request_url for repository "\ - "'%s' specified." % self, - OfflineImapError.ERROR.REPO) - return self.getconf('oauth2_request_url', None) + #raise OfflineImapError("No remote oauth2_request_url for repository " + #"'%s' specified."% self, OfflineImapError.ERROR.REPO) def getoauth2_refresh_token(self): return self.getconf('oauth2_refresh_token', None)