Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
Merge 3424d22 into 5d15aec
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypatel512 committed Jan 4, 2017
2 parents 5d15aec + 3424d22 commit 6e086cb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions paypalrestsdk/api.py
Expand Up @@ -93,11 +93,10 @@ def get_token_hash(self, authorization_code=None, refresh_token=None, headers=No
else:
self.validate_token_hash()
if self.token_hash is not None:
# return cached copy
return self.token_hash
else:
self.token_request_at = datetime.datetime.now()

self.token_hash = self.http_call(
token = self.http_call(
util.join_url(self.token_endpoint, path), "POST",
data=payload,
headers=util.merge_dict({
Expand All @@ -106,7 +105,11 @@ def get_token_hash(self, authorization_code=None, refresh_token=None, headers=No
"Accept": "application/json", "User-Agent": self.user_agent
}, headers or {}))

return self.token_hash
if refresh_token is None and authorization_code is None:
# cache token for re-use in normal case
self.token_request_at = datetime.datetime.now()
self.token_hash = token
return token

def validate_token_hash(self):
"""Checks if token duration has expired and if so resets token
Expand Down

0 comments on commit 6e086cb

Please sign in to comment.