Permalink
Browse files

Fix #218: remove support of OAuth(1)

  • Loading branch information...
mlorant committed Jun 26, 2017
1 parent 8133a9c commit 492ba57f0868b1fd7859933aa4674f37a91f65b5
View
@@ -8,6 +8,9 @@ Changed
-------
- XXX Use built-in TLS when sensible.
Other
-----
* Drop support of OAUTH(1)
===============
Version 1.1.0
@@ -564,7 +567,7 @@ Sphinx Based Docs (#5) [NEW]
Full documentation is now available under doc/html in the source
distribution and at http://imapclient.readthedocs.io/ online.
Added rename_folder (#77) [NEW]
Added rename_folder (#77) [NEW]
--------------------------------
Renaming of folders was an obvious omission!
@@ -607,20 +610,20 @@ A BODYSTRUCTURE response for a multipart email with 2 parts would have
previously looked something like this::
(('text', 'html', ('charset', 'us-ascii'), None, None, 'quoted-printable', 55, 3),
('text', 'plain', ('charset', 'us-ascii'), None, None, '7bit', 26, 1),
('text', 'plain', ('charset', 'us-ascii'), None, None, '7bit', 26, 1),
'mixed', ('boundary', '===============1534046211=='))
The response is now returned like this::
([
('text', 'html', ('charset', 'us-ascii'), None, None, 'quoted-printable', 55, 3),
('text', 'plain', ('charset', 'us-ascii'), None, None, '7bit', 26, 1)
],
('text', 'plain', ('charset', 'us-ascii'), None, None, '7bit', 26, 1)
],
'mixed', ('boundary', '===============1534046211=='))
The behaviour for single part messages is unchanged. In this case the
first element of the tuple is a string specifying the major content
type of the message (eg "text").
type of the message (eg "text").
An is_multipart boolean property now exists on BODY and BODYSTRUCTURE
responses to allow the caller to easily determine whether the response
@@ -660,7 +663,7 @@ argument. These are required for extensions such as RFC 4551
Square brackets in responses now parsed correctly (#55)
-------------------------------------------------------
This fixes response handling for FETCH items such as
This fixes response handling for FETCH items such as
``BODY[HEADER.FIELDS (from subject)]``.
Example moved (#56)
@@ -696,7 +699,7 @@ New response parser (#1, #45)
Command response lexing and parsing code rewritten from stratch to
deal with various bugs that surfaced when dealing with more complex
responses (eg. BODYSTRUCTURE and ENVELOPE). This change also fixes
various problems when interacting with Gmail and MS Exchange.
various problems when interacting with Gmail and MS Exchange.
XLIST extension support (#25) [NEW]
-----------------------------------
@@ -707,7 +710,7 @@ IMAP server supports this.
Added COPY command support (#36) [NEW]
--------------------------------------
New copy() method.
Added interact.py [NEW]
-----------------------
A script for interactive IMAPClient sessions. Useful for debugging and
View
@@ -36,10 +36,6 @@ def get_config_defaults():
timeout=None,
starttls=False,
stream=False,
oauth=False,
oauth_token=None,
oauth_token_secret=None,
oauth_url=None,
oauth2=False,
oauth2_client_id=None,
oauth2_client_secret=None,
@@ -118,11 +114,6 @@ def getfloat(name):
username=get('username'),
password=get('password'),
oauth=getboolean('oauth'),
oauth_url=get('oauth_url'),
oauth_token=get('oauth_token'),
oauth_token_secret=get('oauth_token_secret'),
oauth2=getboolean('oauth2'),
oauth2_client_id=get('oauth2_client_id'),
oauth2_client_secret=get('oauth2_client_secret'),
@@ -183,11 +174,7 @@ def create_client_from_config(conf):
if conf.starttls:
client.starttls()
if conf.oauth:
client.oauth_login(conf.oauth_url,
conf.oauth_token,
conf.oauth_token_secret)
elif conf.oauth2:
if conf.oauth2:
access_token = get_oauth2_token(conf.host,
conf.oauth2_client_id,
conf.oauth2_client_secret,
@@ -3,19 +3,16 @@
from imapclient import IMAPClient
# Populate these with actual values
CONSUMER_KEY = '...'
CONSUMER_SECRET = '...'
OAUTH_TOKEN = '...'
OAUTH_TOKEN_SECRET = '...'
OAUTH2_USER = '...'
OAUTH2_ACCESS_TOKEN = '...'
HOST = 'imap.host.com'
URL = "https://somedomain.com/someuser/imap/"
ssl = True
server = IMAPClient(HOST, use_uid=True, ssl=ssl)
resp = server.oauth_login(URL, OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
CONSUMER_KEY, CONSUMER_SECRET)
resp = server.oauth2_login(URL, OAUTH2_USER, OAUTH2_ACCESS_TOKEN)
print(resp)
select_info = server.select_folder('INBOX')
View
@@ -15,12 +15,6 @@
from six import moves, iteritems, text_type, integer_types, PY3, binary_type, iterbytes
# Confusingly, this module is for OAUTH v1, not v2
try:
import oauth2 as oauth_module
except ImportError:
oauth_module = None
from . import imap4
from . import response_lexer
from . import tls
@@ -215,20 +209,6 @@ def login(self, username, password):
unpack=True,
)
def oauth_login(self, url, oauth_token, oauth_token_secret,
consumer_key='anonymous', consumer_secret='anonymous'):
"""Authenticate using the OAUTH method.
This only works with IMAP servers that support OAUTH (e.g. Gmail).
"""
if oauth_module:
token = oauth_module.Token(oauth_token, oauth_token_secret)
consumer = oauth_module.Consumer(consumer_key, consumer_secret)
xoauth_callable = lambda x: oauth_module.build_xoauth_string(url, consumer, token)
return self._command_and_check('authenticate', 'XOAUTH', xoauth_callable, unpack=True)
else:
raise self.Error('The optional oauth2 package is needed for OAUTH authentication')
def oauth2_login(self, user, access_token, mech='XOAUTH2', vendor=None):
"""Authenticate using the OAUTH2 method.
View
@@ -193,9 +193,6 @@ class TestGeneral(_TestBase):
def test_alternates(self):
# Check alternate connection/login configurations.
for name, conf in iteritems(self.conf.alternates):
if PY3 and conf.oauth:
print("Skipping OAUTH test %r on Python 3 (not compatible)" % name)
continue
try:
client = create_client_from_config(conf)
client.logout()
View
@@ -14,11 +14,6 @@ password = <password>
# ssl = false
# starttls = false
# oauth = false
# oauth_url = ...
# oauth_token = ...
# oauth_token_secret = ...
# oauth2 = false
# oauth2_client_id = ...
# oauth2_client_secret = ...

0 comments on commit 492ba57

Please sign in to comment.