Skip to content

Commit

Permalink
Merge pull request #74 from jamesremuscat/fix/kamereon-token-no-longe…
Browse files Browse the repository at this point in the history
…r-permitted

Remove Kamereon token and don't include it in requests.
  • Loading branch information
jamesremuscat authored Jul 1, 2020
2 parents e6a4f0f + a05dfac commit 652e117
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/pyze/api/kamereon.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,47 +105,6 @@ def get_accounts(self):
def set_account_id(self, account_id):
self._credentials['kamereon-account'] = (account_id, None)

@requires_credentials('gigya', 'gigya-person-id', 'kamereon-api-key')
def get_token(self):
if 'kamereon' in self._credentials:
return self._credentials['kamereon']

response = self._session.get(
'{}/commerce/v1/accounts/{}/kamereon/token?country={}'.format(
self._root_url,
self.get_account_id(),
self._country
),
headers={
'apikey': self._credentials['kamereon-api-key'],
'x-gigya-id_token': self._gigya.get_jwt_token()
}
)

response.raise_for_status()
response_body = response.json()
_log.debug('Received Kamereon token response: {}'.format(response_body))

token = response_body.get('accessToken')
if token:
decoded = jwt.decode(
token,
options={
'verify_signature': False,
'verify_aud': False,
'verify_nbf': False
}
)
self._credentials['kamereon'] = (token, decoded['exp'])
self._clear_all_caches()
return token
else:
raise AccountException(
'Unable to obtain a Kamereon access token! Response included keys {}'.format(
', '.join(response_body.keys())
)
)

@lru_cache(maxsize=1)
@requires_credentials('kamereon-api-key')
def get_vehicles(self):
Expand All @@ -158,7 +117,6 @@ def get_vehicles(self):
headers={
'apikey': self._credentials['kamereon-api-key'],
'x-gigya-id_token': self._gigya.get_jwt_token(),
'x-kamereon-authorization': 'Bearer {}'.format(self.get_token())
}
)

Expand All @@ -184,7 +142,6 @@ def _request(self, method, endpoint, **kwargs):
'Content-type': 'application/vnd.api+json',
'apikey': self._kamereon._credentials['kamereon-api-key'],
'x-gigya-id_token': self._kamereon._gigya.get_jwt_token(),
'x-kamereon-authorization': 'Bearer {}'.format(self._kamereon.get_token())
},
params={
'country': self._kamereon._country
Expand Down

0 comments on commit 652e117

Please sign in to comment.