Skip to content

Commit 073e7e0

Browse files
committed
Merge pull request #5 from tnydwrds/fix-0.3.2-optional-realm-support
Fix 0.3.2 - optional realm support
2 parents a6b6b56 + ea8a93f commit 073e7e0

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

History.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.3.2 / 2013-10-09
2+
==================
3+
* Added: Optional realm support
4+
* `Client.__init__`'s `realm` parameter is now optional (or named).
5+
16
0.3.1 / 2013-06-04
27
==================
38
* Removed: Realm Support
@@ -10,15 +15,13 @@
1015
* Fixed: JSON support for Python 2.4 and 2.5
1116
* Fixed: OAuth support for Python 2.4
1217
* Fixed: Version number below (0.2.1)
13-
1418

1519
0.2.1 / 2012-09-25
1620
==================
1721
# Added: `upload_creative` to support uploading creative files.
1822

1923
0.2.0 / 2012-08-29
2024
==================
21-
2225
* Fixed: JSON parse error when deleting objects with call to `Client.delete()`
2326
* Added: "Official" support for Python 2.4, 2.5, 2.6
2427
* Added: `logon` and `logoff` convenience methods.
@@ -27,5 +30,4 @@
2730

2831
0.1.0 / 2012-08-26
2932
==================
30-
3133
* "Official release"

ox3apiclient/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
if major_py_version == 2 and minor_py_version > 4:
2121
import oauth2 as oauth
2222
else:
23-
import oauth2_version as oauth
23+
import oauth2_version as oauth
2424

2525
import urllib
2626
import urllib2
@@ -33,7 +33,7 @@
3333

3434
import urlparse
3535

36-
__version__ = '0.3.1'
36+
__version__ = '0.3.2'
3737

3838
REQUEST_TOKEN_URL = 'https://sso.openx.com/api/index/initiate'
3939
ACCESS_TOKEN_URL = 'https://sso.openx.com/api/index/token'
@@ -43,7 +43,8 @@
4343

4444
class Client(object):
4545

46-
def __init__(self, domain, realm, consumer_key, consumer_secret,
46+
def __init__(self, domain, consumer_key, consumer_secret,
47+
realm='',
4748
callback_url='oob',
4849
scheme='http',
4950
request_token_url=REQUEST_TOKEN_URL,
@@ -57,9 +58,9 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
5758
"""
5859
5960
domain -- Your UI domain. The API is accessed off this domain.
60-
realm -- This is no longer used. Just specify None.
6161
consumer_key -- Your consumer key.
6262
consumer_secret -- Your consumer secret.
63+
realm -- Optional realm.
6364
callback_url -- Callback URL to redirect to on successful authorization.
6465
We default to 'oob' for headless login.
6566
request_token -- Only override for debugging.
@@ -68,12 +69,13 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
6869
api_path -- Only override for debugging.
6970
http_proxy -- Optional proxy to send HTTP requests through.
7071
"""
71-
72+
7273
self.domain = domain
7374
self.consumer_key = consumer_key
7475
self.consumer_secret = consumer_secret
76+
self.realm = realm
7577
self.callback_url = callback_url
76-
self.scheme=scheme
78+
self.scheme = scheme
7779
self.request_token_url = request_token_url
7880
self.access_token_url = access_token_url
7981
self.authorization_url = authorization_url
@@ -130,8 +132,9 @@ def _sign_request(self, req):
130132
oauth.SignatureMethod_HMAC_SHA1(),
131133
self._consumer,
132134
self._token)
133-
134-
req.headers.update(oauth_req.to_header())
135+
136+
req.headers.update(oauth_req.to_header(realm=self.realm))
137+
135138
return \
136139
urllib2.Request(req.get_full_url(), headers=req.headers, data=data)
137140

@@ -159,7 +162,7 @@ def request(self, url, method='GET', headers={}, data=None, sign=False):
159162
# Everything needs to be UTF-8 for urlencode:
160163
data_utf8 = req.get_data()
161164
for i in data_utf8:
162-
data_utf8[i] = data_utf8[i].encode('utf-8')
165+
data_utf8[i] = data_utf8[i].encode('utf-8')
163166
req.add_data(urllib.urlencode(data_utf8))
164167

165168
# In 2.4 and 2.5, urllib2 throws errors for all non 200 status codes.
@@ -392,6 +395,7 @@ def client_from_file(file_path='.ox3rc', env=None):
392395

393396
# Load optional parameters.
394397
optional_params = [
398+
'realm',
395399
'callback_url',
396400
'scheme',
397401
'request_token_url',

0 commit comments

Comments
 (0)