Browse files

updating OAuth 2.0 service wrapper

  • Loading branch information...
1 parent 9e87e00 commit 169ebbe86b6963431a1749565bf5e2cfb76b5001 @maxcountryman maxcountryman committed Mar 7, 2012
Showing with 9 additions and 7 deletions.
  1. +1 −0 tests/test_service.py
  2. +2 −2 webauth/__init__.py
  3. +6 −5 webauth/service.py
View
1 tests/test_service.py
@@ -34,6 +34,7 @@ def raise_for_status(*args, **kwargs):
response = Mock()
response.content = 'access_token=321'
response.ok = True
+ response.status_code = 200
response.raise_for_status = lambda *args, **kwargs: raise_for_status()
self.response = response
View
4 webauth/__init__.py
@@ -2,8 +2,8 @@
webauth
-------
- OAuth 1.0/a wrapped around Python Requests.
+ OAuth 1.0/a and 2.0 wrapped around Python Requests.
'''
-__version__ = '0.1.2'
+__version__ = '0.1.3'
View
11 webauth/service.py
@@ -21,6 +21,8 @@ def _parse_response(response):
except ValueError:
content = dict(parse_qsl(response.content))
return content
+ # TODO: rather than returning the content in the case of receiving
+ # something we can't parse we should probably raise an error
return response.content
@@ -46,14 +48,13 @@ def get_authorize_url(self, **params):
params = '?' + urlencode(params)
return self.authorize_url + params
- def get_access_token(self, code, **data):
+ def get_access_token(self, **data):
'''Retrieves the access token.'''
data.update(dict(client_id=self.consumer_key,
- client_secret=self.consumer_secret,
- grant_type='authorization_code',
- code=code))
+ client_secret=self.consumer_secret))
- response = requests.post(self.authorize_url, data=data)
+ response = requests.post(self.access_token_url,
+ data=data)
if not response.ok:
response.raise_for_status()

0 comments on commit 169ebbe

Please sign in to comment.