Skip to content

Commit 9734903

Browse files
committed
Changed names for IMAP/SMTP client file names. Fixed minor bug in build_xoauth_string().
1 parent 2540334 commit 9734903

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

oauth2/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ def build_authenticate_header(realm=''):
6565

6666
def build_xoauth_string(url, consumer, token=None):
6767
"""Build an XOAUTH string for use in SMTP/IMPA authentication."""
68-
request = oauth.Request.from_consumer_and_token(consumer, token,
68+
request = Request.from_consumer_and_token(consumer, token,
6969
"GET", url)
7070

71-
signing_method = oauth.SignatureMethod_HMAC_SHA1()
71+
signing_method = SignatureMethod_HMAC_SHA1()
7272
request.sign_request(signing_method, consumer, token)
7373

7474
params = []
7575
for k,v in sorted(request.iteritems()):
7676
if v is not None:
77-
params.append('%s="%s"' % (k, oauth.escape(v)))
77+
params.append('%s="%s"' % (k, escape(v)))
7878

7979
return "%s %s %s" % ("GET", url, ','.join(params))
8080

File renamed without changes.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import oauth2
22
import smtplib
3+
import base64
34

4-
class SMTP(smtplib.SMTP, oauth2.XOAuth):
5+
6+
class SMTP(smtplib.SMTP):
57
def authenticate(self, url, consumer, token):
68
if consumer is not None and not isinstance(consumer, oauth2.Consumer):
79
raise ValueError("Invalid consumer.")
810

911
if token is not None and not isinstance(token, oauth2.Token):
1012
raise ValueError("Invalid token.")
1113

12-
smtp_conn.docmd('AUTH', 'XOAUTH %s' + \
13-
base64.b64encode(oauth2.build_xoauth_string(url, consumer, token))
14+
self.docmd('AUTH', 'XOAUTH %s' + \
15+
base64.b64encode(oauth2.build_xoauth_string(url, consumer, token)))
1416

0 commit comments

Comments
 (0)