XOAUTH2: use one "public" attribute everywhere for self.oauth2_request_url
Improve documentation. Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
be285e522d
commit
b4e33eeac4
@ -801,7 +801,7 @@ remoteuser = username
|
||||
# limitations, if GSSAPI is set, it will be tried first, no matter where it was
|
||||
# specified in the list.
|
||||
#
|
||||
#auth_mechanisms = GSSAPI, CRAM-MD5, XOAUTH2, PLAIN, LOGIN
|
||||
#auth_mechanisms = GSSAPI, XOAUTH2, CRAM-MD5, PLAIN, LOGIN
|
||||
|
||||
|
||||
# This option stands in the [Repository RemoteExample] section.
|
||||
@ -812,7 +812,9 @@ remoteuser = username
|
||||
# with type = IMAP for compatible servers.
|
||||
#
|
||||
# Mandatory parameters are "oauth2_client_id", "oauth2_client_secret" and
|
||||
# either "oauth2_refresh_token" or "oauth2_access_token".
|
||||
# either "oauth2_refresh_token" or "oauth2_access_token". XOAUTH2 mechanism
|
||||
# won't be tried if both oauth2_refresh_token and oauth2_access_token are not
|
||||
# set.
|
||||
#
|
||||
# See below to learn how to get those.
|
||||
#
|
||||
|
@ -47,7 +47,7 @@ class GmailRepository(IMAPRepository):
|
||||
try:
|
||||
return super(GmailRepository, self).gethost()
|
||||
except OfflineImapError:
|
||||
# nothing was configured, cache and return hardcoded one
|
||||
# Nothing was configured, cache and return hardcoded one.
|
||||
self._host = GmailRepository.HOSTNAME
|
||||
return self._host
|
||||
|
||||
@ -60,10 +60,10 @@ class GmailRepository(IMAPRepository):
|
||||
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
|
||||
self.setoauth2_request_url(GmailRepository.OAUTH2_URL)
|
||||
else:
|
||||
self._oauth2_request_url = url
|
||||
return self._oauth2_request_url
|
||||
self.setoauth2_request_url(url)
|
||||
return self.oauth2_request_url
|
||||
|
||||
def getport(self):
|
||||
return GmailRepository.PORT
|
||||
@ -82,8 +82,8 @@ class GmailRepository(IMAPRepository):
|
||||
return folder.Gmail.GmailFolder
|
||||
|
||||
def gettrashfolder(self, foldername):
|
||||
#: Where deleted mail should be moved
|
||||
return self.getconf('trashfolder','[Gmail]/Trash')
|
||||
# Where deleted mail should be moved
|
||||
return self.getconf('trashfolder', '[Gmail]/Trash')
|
||||
|
||||
def getspamfolder(self):
|
||||
#: Gmail also deletes messages upon EXPUNGE in the Spam folder
|
||||
|
@ -36,11 +36,11 @@ class IMAPRepository(BaseRepository):
|
||||
BaseRepository.__init__(self, reposname, account)
|
||||
# self.ui is being set by the BaseRepository
|
||||
self._host = None
|
||||
self._oauth2_request_url = None
|
||||
# Must be set before calling imapserver.IMAPServer(self)
|
||||
self.oauth2_request_url = None
|
||||
self.imapserver = imapserver.IMAPServer(self)
|
||||
self.folders = None
|
||||
self.copy_ignore_eval = None
|
||||
self.oauth2_request_url = None
|
||||
# Keep alive.
|
||||
self.kaevent = None
|
||||
self.kathread = None
|
||||
@ -295,12 +295,15 @@ class IMAPRepository(BaseRepository):
|
||||
value = self.getconf('cert_fingerprint', "")
|
||||
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.
|
||||
return self._oauth2_request_url
|
||||
def setoauth2_request_url(self, url):
|
||||
self.oauth2_request_url = url
|
||||
|
||||
self.oauth2_request_url = self.getconf('oauth2_request_url', None)
|
||||
return self._oauth2_request_url
|
||||
def getoauth2_request_url(self):
|
||||
if self.oauth2_request_url is not None: # Use cached value if possible.
|
||||
return self.oauth2_request_url
|
||||
|
||||
self.setoauth2_request_url(self.getconf('oauth2_request_url', None))
|
||||
return self.oauth2_request_url
|
||||
|
||||
def getoauth2_refresh_token(self):
|
||||
refresh_token = self.getconf('oauth2_refresh_token', None)
|
||||
|
Loading…
Reference in New Issue
Block a user