Skip to content

Commit

Permalink
Add changes from issue below to fix myq login
Browse files Browse the repository at this point in the history
  • Loading branch information
dailow committed Oct 11, 2023
1 parent f6db6a5 commit 4a8ff6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pymyq/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
OAUTH_CLIENT_ID,
OAUTH_REDIRECT_URI,
OAUTH_TOKEN_URI,
OAUTH_LOGIN_URI,
OAUTH_REQUIRED_HEADERS
)
from .device import MyQDevice
from .errors import (
Expand Down Expand Up @@ -382,6 +384,9 @@ async def _oauth_authenticate(self) -> Tuple[str, int]:
if field.get("name") == "__RequestVerificationToken":
data.update({"__RequestVerificationToken": field.get("value") })
have_verification_token = True

# append required headers. See https://github.com/home-assistant/core/issues/101763
data.update(OAUTH_REQUIRED_HEADERS)

# Confirm we found email, password, and submit in the form to be submitted
if have_email and have_password and have_submit and have_verification_token:
Expand All @@ -404,7 +409,7 @@ async def _oauth_authenticate(self) -> Tuple[str, int]:
resp, _ = await self.request(
method="post",
returns="response",
url=resp.url,
url=OAUTH_LOGIN_URI,
websession=session,
headers={
"Content-Type": "application/x-www-form-urlencoded",
Expand Down
8 changes: 6 additions & 2 deletions pymyq/const.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""The myq constants."""

OAUTH_CLIENT_ID = "IOS_CGI_MYQ"
OAUTH_CLIENT_ID = "ANDROID_CGI_MYQ"
OAUTH_CLIENT_SECRET = "VUQ0RFhuS3lQV3EyNUJTdw=="
OAUTH_BASE_URI = "https://partner-identity.myq-cloud.com"
OAUTH_AUTHORIZE_URI = f"{OAUTH_BASE_URI}/connect/authorize"
OAUTH_REDIRECT_URI = "com.myqops://ios"
OAUTH_LOGIN_URI = f"{OAUTH_BASE_URI}/Account/LoginWithEmail"
OAUTH_REDIRECT_URI = "com.myqops://android"
OAUTH_TOKEN_URI = f"{OAUTH_BASE_URI}/connect/token"
OAUTH_REQUIRED_HEADERS = { "brand": "myq",
"UnifiedFlowRequested": True
}

ACCOUNTS_ENDPOINT = "https://accounts.myq-cloud.com/api/v6.0/accounts"
DEVICES_ENDPOINT = (
Expand Down

0 comments on commit 4a8ff6a

Please sign in to comment.