arraylabs / pymyq

Python wrapper for MyQ API
MIT License
112 stars 42 forks source link

Can't login over WIFI ISP, works on mobile data. #145

Open adifelice-godaddy opened 2 years ago

adifelice-godaddy commented 2 years ago

A month ago something changed in the MyQ networking and I'm no longer able to login/authenticate via my WIFI/ISP network, same even using the MyQ app. Works fine when using mobile data LTE.

I wonder if anyone else is facing a similar issue or my router is somehow messing things up.

Thanks.

Goose66 commented 2 years ago

Not sure about significance of “Wi-fi ISP” distinction, but my mobile app continues to work over Wi-fi w/ gigabit fiber ISP

adifelice-godaddy commented 2 years ago

I'm not sure if ISP is related or not but after some testing, here a better picture of what is happening:

Tests

✅ On a VPN works via pymyq:

$ python test.py 
{'<serial>': <pymyq.garagedoor.MyQGaragedoor object at 0x10e241580>}

❌ On my ISP network fails:

$ python test.py --log=DEBUG
Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/authorize: 400 - Bad Request
Traceback (most recent call last):
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/pymyq/api.py", line 207, in request
    return await call_method(
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/pymyq/request.py", line 297, in request_text
    resp = await self._send_request(
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/pymyq/request.py", line 207, in _send_request
    raise resp_exc
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/pymyq/request.py", line 141, in _send_request
    resp = await websession.request(
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/aiohttp/client.py", line 640, in _request
    resp.raise_for_status()
  File "/Users/user/.virtualenvs/myq/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://partner-identity.myq-cloud.com/connect/authorize?client_id=IOS_CGI_MYQ&code_challenge=pEZgp7jZ_7WWHqCp5XZmdi-lU2Y22Ka7lWSOCi1i7Y8&code_challenge_method=S256&redirect_uri=com.myqops://ios&response_type=code&scope=MyQ_Residential+offline_access')

❌ On iPhone via MyQ app: IMG_4543F69C45F8-1

❌ Home Assistant:

2022-03-29 08:07:02 ERROR (MainThread) [pymyq.api] Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/authorize: 400 - Bad Request

Tracing route and DNS resolution

From VPN:

$ traceroute partner-identity.myq-cloud.com
traceroute to partner-identity-west.myq-cloud.com (13.83.98.203), 64 hops max, 52 byte packets

$ dig partner-identity.myq-cloud.com +short
myq-partner-identity.trafficmanager.net.
partner-identity-west.myq-cloud.com.
13.83.98.203

From my ISP:

$ traceroute partner-identity.myq-cloud.com
traceroute to partner-identity-east.myq-cloud.com (40.71.237.110), 64 hops max, 52 byte packets

$ dig partner-identity.myq-cloud.com +short
;; Warning: Message parser reports malformed message packet.
10 8 MDo/zC9+xJ8=

$ dig partner-identity.myq-cloud.com +short
myq-partner-identity.trafficmanager.net.
partner-identity-east.myq-cloud.com.
40.71.237.110

$ dig partner-identity.myq-cloud.com +short
;; Warning: Message parser reports malformed message packet.
10 8 C9GBUXJMr/I=

It seems like something has changed recently.

mbbush commented 1 year ago

There's some kind of network problem between your ISP and the myq server, or perhaps with the DNS servers your ISP gives you (since the dig command failed).

It looks like partner-identity-east.myq-cloud.com doesn't work properly for you. It's probably Chamberlain's fault on the server side.

If you override your DNS to a public dns server (google, cloudflare, opendns, take your pick), does that resolve the problem?

If not, complain to Chamberlain because their app doesn't work (since you get the same error using the official first-party app).