XOAUTH2: fix the *_eval configuration options

They introduce a regression not allowing to discard the XOAUTH2 method when
expected.

The default lambda did not take the "account_name" argument.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/362
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-07-29 16:38:58 +02:00
parent ddbc1426d5
commit 9aa5afa951
2 changed files with 20 additions and 17 deletions

View File

@ -309,28 +309,36 @@ class IMAPRepository(BaseRepository):
refresh_token = self.getconf('oauth2_refresh_token', None)
if refresh_token is None:
refresh_token = self.localeval.eval(
self.getconf('oauth2_refresh_token_eval', "lambda: None"))
self.getconf('oauth2_refresh_token_eval',
"lambda x: None")
)(self.account.getname())
return refresh_token
def getoauth2_access_token(self):
access_token = self.getconf('oauth2_access_token', None)
if access_token is None:
access_token = self.localeval.eval(
self.getconf('oauth2_access_token_eval', "lambda: None"))
self.getconf('oauth2_access_token_eval',
"lambda x: None")
)(self.account.getname())
return access_token
def getoauth2_client_id(self):
client_id = self.getconf('oauth2_client_id', None)
if client_id is None:
client_id = self.localeval.eval(
self.getconf('oauth2_client_id_eval', "lambda: None"))
self.getconf('oauth2_client_id_eval',
"lambda x: None")
)(self.account.getname())
return client_id
def getoauth2_client_secret(self):
client_secret = self.getconf('oauth2_client_secret', None)
if client_secret is None:
client_secret = self.localeval.eval(
self.getconf('oauth2_client_secret_eval', "lambda: None"))
self.getconf('oauth2_client_secret_eval',
"lambda x: None")
)(self.account.getname())
return client_secret
def getpreauthtunnel(self):