File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,16 +65,16 @@ def build_authenticate_header(realm=''):
6565
6666def 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.
Original file line number Diff line number Diff line change 11import oauth2
22import 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
You can’t perform that action at this time.
0 commit comments