Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to python3 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hubspot_oauth2client/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1'
__version__ = '0.2'
15 changes: 10 additions & 5 deletions hubspot_oauth2client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

import requests

try:
urlencode = urllib.urlencode
except AttributeError:
urlencode = urllib.parse.urlencode


TOKEN_REQUEST_HEADERS = {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
Expand Down Expand Up @@ -44,7 +49,7 @@ def step1_get_authorize_url(self):

url = '{base}?{params}'.format(
base=self.authorize_url,
params=urllib.urlencode(params))
params=urlencode(params))

return url

Expand Down Expand Up @@ -82,8 +87,8 @@ def create_credentials_from_code_exchange(self, resp):
token_expires_on = token_obtained_on + token_lifetime_seconds

try:
access_token = unicode(datadict['access_token'])
refresh_token = unicode(datadict['refresh_token'])
access_token = str(datadict['access_token'])
refresh_token = str(datadict['refresh_token'])
except KeyError:
raise BadCodeExchangeResponse("Missing access or refresh token")
except UnicodeDecodeError:
Expand Down Expand Up @@ -180,8 +185,8 @@ def refresh(self):
token_expires_on = token_obtained_on + token_lifetime_seconds

try:
access_token = unicode(datadict['access_token'])
refresh_token = unicode(datadict['refresh_token'])
access_token = str(datadict['access_token'])
refresh_token = str(datadict['refresh_token'])
except KeyError:
raise BadCodeExchangeResponse("Missing access or refresh token")
except UnicodeDecodeError:
Expand Down