XOAUTH2: let the user call the evaluated functions in the configuration

Don't pass the account name to the function returned by eval. This allows the
user to define his own arguments.

This fix the code according to the documentation provided in offlineimap.conf.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/372
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-08-14 22:35:09 +02:00
parent 560363ef73
commit b4fe69028b

View File

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