Skip to content

Commit

Permalink
fix: fix get_authorization_code syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed May 1, 2021
1 parent 1da98b6 commit ef46aef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions teslajsonpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,12 @@ async def get_authorization_code(
if resp.history:
for item in resp.history:
if (
item.status in [301, 302, 303, 304, 305, 306, 307, 308]
item.status_code in [301, 302, 303, 304, 305, 306, 307, 308]
and resp.url.host != self.auth_domain.host
):
_LOGGER.debug(
"Detected %s redirect from %s to %s; changing proxy host",
item.status,
item.status_code,
item.url.host,
resp.url.host,
)
Expand Down Expand Up @@ -487,10 +487,10 @@ async def get_authorization_code(
resp = await self.websession.post(str(url), data=data)
_process_resp(resp)
await asyncio.sleep(3)
if not resp.history or not URL(resp.history[-1].url).query.get("code"):
if not resp.history or not URL(str(resp.history[-1].url)).query.get("code"):
_LOGGER.debug("Failed to authenticate")
raise IncompleteCredentials("Unable to login with credentials")
code_url = URL(resp.history[-1].url)
code_url = URL(str(resp.history[-1].url))
_LOGGER.debug("Found code %s", code_url.query.get("code"))
return code_url.query.get("code")

Expand Down Expand Up @@ -599,7 +599,7 @@ def get_inputs(soup: BeautifulSoup, searchfield=None) -> Dict[str, str]:
def _process_resp(resp) -> Text:
if resp.history:
for item in resp.history:
_LOGGER.debug("%s: redirected from\n%s", item.method, item.url)
_LOGGER.debug("%s: redirected from\n%s", item.resp.method, item.url)
url = str(resp.request.url)
method = resp.request.method
status = resp.status_code
Expand Down

0 comments on commit ef46aef

Please sign in to comment.