Skip to content

Commit

Permalink
fix(zodiac): auth refresh only working once
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiga1993 committed Jun 29, 2024
1 parent cfb5b8e commit 2663632
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pollect/libs/zodiac/ZodiacApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ def login(self, email: str, password: str) -> LoginReply:
return dto

def refresh_auth(self) -> LoginReply:
current_refresh_token = self.user.userPoolOAuth.RefreshToken
body = {
'email': self.user.email,
'refresh_token': self.user.userPoolOAuth.RefreshToken
}
dto = self._post(f'{self.SHADOW_URL}/users/v1/refresh', body, LoginReply())
if dto.userPoolOAuth.RefreshToken == '':
# API didn't reply with refresh token, keep current
dto.userPoolOAuth.RefreshToken = current_refresh_token
self.user = dto
return dto

Expand Down
2 changes: 2 additions & 0 deletions pollect/sources/ZodiacPoolSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def setup(self, global_conf):
self.api.login(self._user, self._password)
self._persist_auth()
return

with open(self.AUTH_FILE, "r") as f:
login_data = json.load(f)

Expand All @@ -52,6 +53,7 @@ def _probe(self) -> Optional[ValueSet] or List[ValueSet]:
remaining = robot.get_remaining_time()

values.add(Value(remaining, [device.serial_number], 'remaining_time'))

self._persist_auth()
return values

Expand Down

0 comments on commit 2663632

Please sign in to comment.