Skip to content

Commit

Permalink
fix: Handle missing refresh token properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Birkner authored and BirknerAlex committed Dec 23, 2024
1 parent 4968cd3 commit 5cb3533
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion custom_components/einskomma5grad/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def get_token(self) -> str:

# Check for expiration and refresh token
if self.is_token_expiring(60):
return self.refresh_token()
try:
return self.refresh_token()
except AuthenticationError:
return self.login()

return self.token_set["access_token"]

Expand Down Expand Up @@ -146,6 +149,9 @@ def refresh_token(self) -> str:
if self.token_set is None:
raise AuthenticationError("No token set")

if "refresh_token" not in self.token_set:
raise AuthenticationError("No refresh token found")

res = requests.post(
url=self.TOKEN_URL,
json={
Expand Down

0 comments on commit 5cb3533

Please # to comment.