offlineimap.conf: learn to evaluate oauth2 related options
Introduce: - oauth2_client_id_eval - oauth2_client_secret_eval - oauth2_access_token_eval - oauth2_refresh_token_eval Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/307 Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
a1efae0703
commit
b521b98d99
@ -829,6 +829,10 @@ remoteuser = username
|
||||
#
|
||||
#oauth2_client_id = YOUR_CLIENT_ID
|
||||
#oauth2_client_secret = YOUR_CLIENT_SECRET
|
||||
#
|
||||
# The return values must be bytes.
|
||||
#oauth2_client_id_eval = get_client_id("accountname")
|
||||
#oauth2_client_secret_eval = get_client_secret("accountname")
|
||||
|
||||
# Specify the refresh token to use for the connection to the mail server.
|
||||
# Here's an example of a way to get a refresh token:
|
||||
@ -853,6 +857,10 @@ remoteuser = username
|
||||
#oauth2_access_token = ACCESS_TOKEN
|
||||
#oauth2_request_url = https://accounts.google.com/o/oauth2/token
|
||||
#oauth2_refresh_token = REFRESH_TOKEN
|
||||
#
|
||||
# The return values must be bytes.
|
||||
#oauth2_access_token_eval = get_access_token("accountname")
|
||||
#oauth2_refresh_token_eval = get_refresh_token("accountname")
|
||||
|
||||
########## Passwords
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
from sys import exc_info
|
||||
import six
|
||||
|
||||
try:
|
||||
from ConfigParser import SafeConfigParser, Error
|
||||
|
@ -301,16 +301,32 @@ class IMAPRepository(BaseRepository):
|
||||
return self._oauth2_request_url
|
||||
|
||||
def getoauth2_refresh_token(self):
|
||||
return self.getconf('oauth2_refresh_token', None)
|
||||
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"))
|
||||
return refresh_token
|
||||
|
||||
def getoauth2_access_token(self):
|
||||
return self.getconf('oauth2_access_token', None)
|
||||
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"))
|
||||
return access_token
|
||||
|
||||
def getoauth2_client_id(self):
|
||||
return self.getconf('oauth2_client_id', None)
|
||||
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"))
|
||||
return client_id
|
||||
|
||||
def getoauth2_client_secret(self):
|
||||
return self.getconf('oauth2_client_secret', None)
|
||||
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"))
|
||||
return client_secret
|
||||
|
||||
def getpreauthtunnel(self):
|
||||
return self.getconf('preauthtunnel', None)
|
||||
@ -325,8 +341,7 @@ class IMAPRepository(BaseRepository):
|
||||
return self.getconfboolean('decodefoldernames', False)
|
||||
|
||||
def getidlefolders(self):
|
||||
localeval = self.localeval
|
||||
return localeval.eval(self.getconf('idlefolders', '[]'))
|
||||
return self.localeval.eval(self.getconf('idlefolders', '[]'))
|
||||
|
||||
def getmaxconnections(self):
|
||||
num1 = len(self.getidlefolders())
|
||||
|
Loading…
Reference in New Issue
Block a user