Allow authorization via XOAUTH2 using access token
Signed-off-by: Slava Kardakov <ojab@ojab.ru> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
72850e3c23
commit
cfa704bbf2
@ -769,7 +769,8 @@ remoteuser = username
|
||||
# with type = IMAP for compatible servers).
|
||||
#
|
||||
# Mandatory parameters are "oauth2_client_id", "oauth2_client_secret" and
|
||||
# "oauth2_refresh_token". See below to learn how to get those.
|
||||
# either "oauth2_refresh_token" or "oauth2_access_token".
|
||||
# See below to learn how to get those.
|
||||
#
|
||||
# Specify the OAuth2 client id and secret to use for the connection..
|
||||
# Here's how to register an OAuth2 client for Gmail, as of 10-2-2016:
|
||||
@ -791,8 +792,12 @@ remoteuser = username
|
||||
# - Type the following command-line in a terminal and follow the instructions
|
||||
# python python/oauth2.py --generate_oauth2_token \
|
||||
# --client_id=YOUR_CLIENT_ID --client_secret=YOUR_CLIENT_SECRET
|
||||
# - Access token can be obtained using refresh token with command
|
||||
# python python/oauth2.py --user=YOUR_EMAIL --client_id=YOUR_CLIENT_ID
|
||||
# --client_secret=YOUR_CLIENT_SECRET --refresh_token=REFRESH_TOKEN
|
||||
#
|
||||
#oauth2_refresh_token = REFRESH_TOKEN
|
||||
#oauth2_access_token = ACCESS_TOKEN
|
||||
|
||||
########## Passwords
|
||||
|
||||
|
@ -95,10 +95,10 @@ class IMAPServer:
|
||||
self.tlslevel = repos.gettlslevel()
|
||||
|
||||
self.oauth2_refresh_token = repos.getoauth2_refresh_token()
|
||||
self.oauth2_access_token = repos.getoauth2_access_token()
|
||||
self.oauth2_client_id = repos.getoauth2_client_id()
|
||||
self.oauth2_client_secret = repos.getoauth2_client_secret()
|
||||
self.oauth2_request_url = repos.getoauth2_request_url()
|
||||
self.oauth2_access_token = None
|
||||
|
||||
self.delim = None
|
||||
self.root = None
|
||||
@ -212,7 +212,7 @@ class IMAPServer:
|
||||
|
||||
|
||||
def __xoauth2handler(self, response):
|
||||
if self.oauth2_refresh_token is None:
|
||||
if self.oauth2_refresh_token is None and self.oauth2_access_token is None:
|
||||
return None
|
||||
|
||||
if self.oauth2_access_token is None:
|
||||
|
@ -276,6 +276,9 @@ class IMAPRepository(BaseRepository):
|
||||
def getoauth2_refresh_token(self):
|
||||
return self.getconf('oauth2_refresh_token', None)
|
||||
|
||||
def getoauth2_access_token(self):
|
||||
return self.getconf('oauth2_access_token', None)
|
||||
|
||||
def getoauth2_client_id(self):
|
||||
return self.getconf('oauth2_client_id', None)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user