Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

correcting oversight with setting response_type and grant_type

  • Loading branch information...
commit 50ae1c2fb8c404ccf4276d9a4e7e5348ff214ed7 1 parent a38ca1a
@maxcountryman maxcountryman authored
View
13 tests/test_service.py
@@ -54,6 +54,12 @@ def test_get_authorize_url(self):
'http://example.com/authorize?response_type=code&client_id=123'
self.assertEqual(expected_url, authorize_url)
+ def test_get_authorize_url_response_type(self):
+ authorize_url = self.service.get_authorize_url(response_type='token')
+ expected_url = \
+ 'http://example.com/authorize?response_type=token&client_id=123'
+ self.assertEqual(expected_url, authorize_url)
+
@patch.object(requests.Session, 'request')
def test_get_access_token(self, mock_request):
mock_request.return_value = self.response
@@ -70,6 +76,13 @@ def test_get_access_token_bad_response(self, mock_request):
self.assertEqual('Response not OK!', str(e))
@patch.object(requests.Session, 'request')
+ def test_get_access_token_grant_type(self, mock_request):
+ mock_request.return_value = self.response
+ response = self.service.get_access_token(code='4242',
+ grant_type='refresh_token')
+ self.assertEqual(response['access_token'], '321')
+
+ @patch.object(requests.Session, 'request')
def test_request(self, mock_request):
self.response.content = json.dumps({'status': 'ok'})
mock_request.return_value = self.response
View
2  webauth/__init__.py
@@ -6,4 +6,4 @@
'''
-__version__ = '0.1.4'
+__version__ = '0.1.5'
View
4 webauth/service.py
@@ -89,6 +89,8 @@ def get_authorize_url(self, response_type=None, **params):
# defaults to 'code'
if response_type is None:
params.update({'response_type': 'code'})
+ elif response_type is not None:
+ params.update({'response_type': response_type})
params.update({'client_id': self.consumer_key})
params = '?' + urlencode(params)
@@ -105,6 +107,8 @@ def get_access_token(self, grant_type=None, **data):
# defaults to authorization_code
if grant_type is None:
data.update({'grant_type': 'authorization_code'})
+ elif grant_type is not None:
+ data.update({'grant_type': grant_type})
data.update(dict(client_id=self.consumer_key,
client_secret=self.consumer_secret))
Please sign in to comment.
Something went wrong with that request. Please try again.