Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pymyq/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Define the MyQ API."""
import asyncio
import base64
import logging
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Tuple, Union
Expand All @@ -20,7 +21,6 @@
OAUTH_AUTHORIZE_URI,
OAUTH_BASE_URI,
OAUTH_CLIENT_ID,
OAUTH_CLIENT_SECRET,
OAUTH_REDIRECT_URI,
OAUTH_TOKEN_URI,
)
Expand Down Expand Up @@ -440,24 +440,22 @@ async def _oauth_authenticate(self) -> Tuple[str, int]:
_LOGGER.debug("Getting token")
redirect_url = f"{OAUTH_BASE_URI}{resp.headers['Location']}"

get_token_basic_auth = base64.b64encode(f"{OAUTH_CLIENT_ID}:".encode("ascii")).decode("ascii")
resp, data = await self.request(
returns="json",
method="post",
url=OAUTH_TOKEN_URI,
websession=session,
headers={
"Authorization": f"Basic {get_token_basic_auth}",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "*/*",
},
data={
"client_id": OAUTH_CLIENT_ID,
"client_secret": OAUTH_CLIENT_SECRET,
"code": parse_qs(urlsplit(redirect_url).query).get("code", ""),
"code": parse_qs(urlsplit(redirect_url).query).get("code", "")[0],
"code_verifier": self._code_verifier,
"grant_type": "authorization_code",
"redirect_uri": OAUTH_REDIRECT_URI,
"scope": parse_qs(urlsplit(redirect_url).query).get(
"code", "MyQ_Residential offline_access"
),
},
login_request=True,
)
Expand Down