From 839518a92ca4606924aafe91bd8a382fd49d6a17 Mon Sep 17 00:00:00 2001 From: Menno Smits Date: Mon, 12 Jan 2015 23:34:55 +1300 Subject: [PATCH] Cleaned up OAUTH2 auth string generation --- imapclient/imapclient.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index 5dabe2a..ee2bc7f 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -168,14 +168,14 @@ class IMAPClient(object): def oauth2_login(self, user, access_token, mech='XOAUTH2', vendor=None): """Authenticate using the OAUTH2 method. - Gmail and Yahoo both support the 'XOAUTH2' mechanism, but Yahoo requires + Gmail and Yahoo both support the 'XOAUTH2' mechanism, but Yahoo requires the 'vendor' portion in the payload. """ + auth_string = 'user=%s\1auth=Bearer %s\1' % (user, access_token) if vendor: - auth_string = lambda x: 'user=%s\1auth=Bearer %s\1vendor=%s\1\1' % (user, access_token, vendor) - else: - auth_string = lambda x: 'user=%s\1auth=Bearer %s\1\1' % (user, access_token) - return self._command_and_check('authenticate', mech, auth_string) + auth_string += 'vendor=%s\1' % vendor + auth_string += '\1' + return self._command_and_check('authenticate', mech, lambda x: auth_string) def logout(self): """Logout, returning the server response. -- 2.43.0