Skip to content

Commit

Permalink
fix: changed header param name
Browse files Browse the repository at this point in the history
from scwebtoken to southerjwtcookie
  • Loading branch information
Lash-L committed Feb 7, 2023
1 parent 3d71849 commit bde8afb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/southern_company_api/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def _get_sc_web_token(self) -> str:
else:
raise NoScTokenFound("Login request did not return a sc token")

async def _get_secondary_sc_token(self) -> str:
async def _get_southern_jwt_cookie(self) -> str:
if self.sc is None:
await self._get_sc_web_token()
data = {"ScWebToken": self.sc}
Expand All @@ -107,8 +107,8 @@ async def _get_secondary_sc_token(self) -> str:
f"{resp.headers} {data}"
)
# Regex to parse JWT out of headers
swtregex = re.compile(r"ScWebToken=(\S*);", re.IGNORECASE)

# NOTE: This used to be ScWebToken before 02/07/2023
swtregex = re.compile(r"SouthernJwtCookie=(\S*);", re.IGNORECASE)
# Parsing response header to get token
swtcookies = resp.headers.get("set-cookie")
if swtcookies:
Expand All @@ -130,9 +130,10 @@ async def _get_secondary_sc_token(self) -> str:

async def get_jwt(self) -> str:
# Trading ScWebToken for Jwt
swtoken = await self._get_secondary_sc_token()
swtoken = await self._get_southern_jwt_cookie()
# Now fetch JWT after secondary ScWebToken
headers = {"Cookie": f"ScWebToken={swtoken}"}
# NOTE: This used to be ScWebToken before 02/07/2023
headers = {"Cookie": f"SouthernJwtCookie={swtoken}"}
async with aiohttp.ClientSession() as session:
async with session.get(
"https://customerservice2.southerncompany.com/Account/LoginValidated/"
Expand Down
5 changes: 5 additions & 0 deletions tests/test_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from southern_company_api import Account, Company


def test_can_create():
Account("sample", True, "1", Company.GPC)

0 comments on commit bde8afb

Please sign in to comment.