Skip to content

Commit

Permalink
Merge pull request #200 from natekspencer/dev
Browse files Browse the repository at this point in the history
Add helper to get refresh_token
  • Loading branch information
natekspencer authored Oct 7, 2024
2 parents cd25fdc + eda1f55 commit 6c96e5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vivintpy/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def connected(self) -> bool:
"""Return True if connected."""
return self.__connected

@property
def refresh_token(self) -> str | None:
"""Return the refresh token."""
return self.api.tokens.get("refresh_token")

async def connect(
self, load_devices: bool = False, subscribe_for_realtime_updates: bool = False
) -> None:
Expand Down
5 changes: 5 additions & 0 deletions vivintpy/vivintskyapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def __init__(
self.__mfa_type = "code"
self.__token: dict | None = None

@property
def tokens(self) -> dict:
"""Return the tokens, if any."""
return self.__token or {}

def is_session_valid(self) -> bool:
"""Return `True` if the token is still valid."""
if self.__token is None:
Expand Down

0 comments on commit 6c96e5b

Please sign in to comment.