@@ -17,6 +17,7 @@ class OX3APIClient(object):
1717
1818 def __init__ (self , domain , realm , consumer_key , consumer_secret ,
1919 callback_url = 'oob' ,
20+ scheme = 'http' ,
2021 request_token_url = REQUEST_TOKEN_URL ,
2122 access_token_url = ACCESS_TOKEN_URL ,
2223 authorization_url = AUTHORIZATION_URL ,
@@ -39,10 +40,11 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
3940 self .realm = realm
4041 self .consumer_key = consumer_key
4142 self .consumer_secret = consumer_secret
43+ self .callback_url = callback_url
44+ self .scheme = scheme
4245 self .request_token_url = request_token_url
4346 self .access_token_url = access_token_url
4447 self .authorization_url = authorization_url
45- self .callback_url = callback_url
4648 self .api_path = api_path
4749
4850 # You shouldn't need to access the oauth2 consumer and token objects
@@ -53,7 +55,9 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
5355 # Similarly you probably won't need to access the cookie jar directly,
5456 # so it is private as well.
5557 self ._cookie_jar = cookielib .LWPCookieJar ()
56- opener = urllib2 .build_opener (urllib2 .HTTPCookieProcessor (self ._cookie_jar ))
58+ opener = \
59+ urllib2 .build_opener (urllib2 .HTTPCookieProcessor (self ._cookie_jar ))
60+
5761 urllib2 .install_opener (opener )
5862
5963 def _sign_request (self , req ):
@@ -86,7 +90,8 @@ def _sign_request(self, req):
8690 # Update or original requests headers to include the OAuth Authorization
8791 # header and return it.
8892 req .headers .update (oauth_req .to_header (realm = self .realm ))
89- return urllib2 .Request (req .get_full_url (), headers = req .headers , data = data )
93+ return \
94+ urllib2 .Request (req .get_full_url (), headers = req .headers , data = data )
9095
9196 def request (self , url , method = 'GET' , headers = {}, data = None , sign = False ):
9297 """Helper method to make a (optionally OAuth signed) HTTP request."""
@@ -168,15 +173,19 @@ def validate_session(self):
168173
169174 self ._cookie_jar .set_cookie (cookie )
170175
171- url = 'http://' + self .domain + self .api_path + '/a/session/validate'
176+ url = '%s://%s%s/a/session/validate' % (self .scheme ,
177+ self .domain ,
178+ self .api_path )
179+
172180 res = self .request (url = url , method = 'PUT' )
173181 return res .read ()
174182
175183 def _resolve_url (self , url ):
176184 """"""
177185 parse_res = urlparse .urlparse (url )
178186 if not parse_res .scheme :
179- url = 'http://%s%s%s' % (self .domain , self .api_path , parse_res .path )
187+ url = '%s://%s%s%s' % (self .scheme , self .domain , self .api_path ,
188+ parse_res .path )
180189
181190 return url
182191
0 commit comments