Skip to content

Commit

Permalink
fix: always make call to property
Browse files Browse the repository at this point in the history
  • Loading branch information
Lash-L committed Feb 14, 2023
1 parent 48acc33 commit a162506
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/southern_company_api/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,8 @@ async def authenticate(self) -> bool:

async def _get_sc_web_token(self) -> str:
"""Gets a sc_web_token which we get from a successful log in"""
# update to use property
if (
self._request_token is None
or datetime.datetime.now() >= self._request_token_expiry
):
self._request_token = await get_request_verification_token()
self._request_token_expiry = datetime.datetime.now() + datetime.timedelta(
hours=3
)
if await self.request_token is None:
raise CantReachSouthernCompany("Request Token could not be refreshed")
headers = {
"Content-Type": "application/json; charset=utf-8",
"RequestVerificationToken": self._request_token,
Expand Down Expand Up @@ -143,8 +136,8 @@ async def _get_sc_web_token(self) -> str:

async def _get_southern_jwt_cookie(self) -> str:
# update to use property
if self._sc is None or datetime.datetime.now() >= self._sc_expiry:
self._sc = await self._get_sc_web_token()
if await self.sc is None:
raise CantReachSouthernCompany("Sc token cannot be refreshed")
data = {"ScWebToken": self._sc}
async with aiohttp.ClientSession() as session:
async with session.post(
Expand Down

0 comments on commit a162506

Please sign in to comment.