Skip to content

Commit

Permalink
Specify user agent for a request I missed earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
tronikos committed Jul 31, 2023
1 parent 28a4efd commit 8d7f2a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "opower"
version = "0.0.17"
version = "0.0.18"
license = {text = "Apache-2.0"}
authors = [
{ name="tronikos", email="[email protected]" },
Expand Down
2 changes: 2 additions & 0 deletions src/opower/opower.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def __init__(
self, session: aiohttp.ClientSession, utility: str, username: str, password: str
) -> None:
"""Initialize."""
# Note: Do not modify default headers since Home Assistant that uses this library needs to use
# a default session for all integrations. Instead specify the headers for each request.
self.session = session
self.utility: type[UtilityBase] = _select_utility(utility)
self.username = username
Expand Down
6 changes: 4 additions & 2 deletions src/opower/utilities/exelon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async def async_login(
) -> str:
"""Login to the utility website and authorize opower."""
async with session.get(
"https://" + cls.login_domain() + "/Pages/Login.aspx?/login"
"https://" + cls.login_domain() + "/Pages/Login.aspx?/login",
headers={"User-Agent": USER_AGENT},
raise_for_status=True,
) as resp:
result = await resp.text()
# transId = "StateProperties=..."
Expand Down Expand Up @@ -90,7 +92,7 @@ async def async_login(
headers={"User-Agent": USER_AGENT},
raise_for_status=True,
) as resp:
result = await resp.text(encoding = "utf-8")
result = await resp.text(encoding="utf-8")

async with session.post(
"https://"
Expand Down

0 comments on commit 8d7f2a9

Please sign in to comment.