Skip to content

Commit

Permalink
Merge pull request #32 from teleshoes/fix_headers_reuse
Browse files Browse the repository at this point in the history
fix: do not update global HEADERS var (breaks re-login attempt)
  • Loading branch information
w1ll1am23 authored Apr 5, 2023
2 parents c8bd6d7 + 10af74b commit c171a89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pyeconet/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ async def get_equipment_by_type(self, equipment_type: List) -> Dict:
return _equipment

async def _get_location(self) -> List[Dict]:
_headers = HEADERS
_headers = HEADERS.copy()
_headers["ClearBlade-UserToken"] = self._user_token

_session = ClientSession()
try:
async with _session.post(
f"{REST_URL}/code/{CLEAR_BLADE_SYSTEM_KEY}/getLocation", headers=HEADERS
f"{REST_URL}/code/{CLEAR_BLADE_SYSTEM_KEY}/getLocation", headers=_headers
) as resp:
if resp.status == 200:
_json = await resp.json()
Expand All @@ -204,15 +204,15 @@ async def _get_location(self) -> List[Dict]:
await _session.close()

async def get_dynamic_action(self, payload: Dict) -> Dict:
_headers = HEADERS
_headers = HEADERS.copy()
_headers["ClearBlade-UserToken"] = self._user_token

_session = ClientSession()
try:
async with _session.post(
f"{REST_URL}/code/{CLEAR_BLADE_SYSTEM_KEY}/dynamicAction",
json=payload,
headers=HEADERS,
headers=_headers,
) as resp:
if resp.status == 200:
_json = await resp.json()
Expand Down

0 comments on commit c171a89

Please sign in to comment.