Skip to content

Commit 6cd7e07

Browse files
committed
Deletes inneccesary comments.
1 parent 90e18f6 commit 6cd7e07

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

surveymonkey/client.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,37 @@
2323

2424
class Client(object):
2525

26-
def __init__(self, access_token):
26+
def __init__(self, client_id=None, client_secret=None, redirect_uri=None, access_token=None):
27+
self.code = None
28+
self.client_id = client_id
29+
self.redirect_uri = redirect_uri
30+
self.client_secret = client_secret
2731
self._access_token = access_token
2832

2933
# Authorization
30-
def get_authorization_url(self, client_id, redirect_uri):
34+
def get_authorization_url(self):
3135
"""
3236
33-
:param client_id:
34-
:param redirect_uri:
3537
:return:
3638
"""
37-
params = {'client_id': client_id, 'redirect_uri': redirect_uri, 'response_type': 'code'}
39+
params = {'client_id': self.client_id, 'redirect_uri': self.redirect_uri, 'response_type': 'code'}
3840
url = BASE_URL + AUTH_CODE + '?' + urlencode(params)
3941
return url
4042

41-
def exchange_code(self, code, client_id, client_secret, redirect_uri):
43+
def exchange_code(self, code):
4244
"""
4345
4446
:param code:
45-
:param client_id:
46-
:param client_secret:
47-
:param redirect_uri:
4847
:return:
4948
"""
50-
params = {'code': code, 'client_id': client_id, 'client_secret': client_secret,
51-
'redirect_uri': redirect_uri, 'grant_type': 'authorization_code'}
52-
url = BASE_URL + ACCESS_TOKEN_URL + '?' + urlencode(params)
53-
return self._post(url, data=params)
49+
params = {'code': code, 'client_id': self.client_id, 'client_secret': self.client_secret,
50+
'redirect_uri': self.redirect_uri, 'grant_type': 'authorization_code'}
51+
url = BASE_URL + ACCESS_TOKEN_URL
52+
response = requests.post(url, data=params)
53+
if response.status_code == 200 and 'access_token' in response.text:
54+
return response.text
55+
else:
56+
return False
5457

5558
def refresh_token(self):
5659
"""
@@ -724,9 +727,9 @@ def _parse(self, response):
724727
def get_error(self, error):
725728
"""
726729
727-
:return:
730+
:return:
728731
"""
729-
error_code = error['error']['id']
732+
error_code = error['error']
730733
error_message = error['message']
731734
if error_code == "1000":
732735
raise BadRequestError(error_message)

0 commit comments

Comments
 (0)