core: MyQ login error: 401 Unauthorized

The problem

The MyQ integration fails to connect, and the error in the log says 401 Unauthorized. I tried resetting the password and adding a co-owner nothing worked.

image

Logger: pymyq.api
Source: components/myq/config_flow.py:37
First occurred: 10:06:43 (7 occurrences)
Last logged: 11:42:57

Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/token: 401 - Unauthorized

What version of Home Assistant Core has the issue?

core-2023.8.0

What was the last working version of Home Assistant Core?

core-2023.6.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

MyQ

Link to integration documentation on our website

https://www.home-assistant.io/integrations/myq/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-08-04 10:00:02.084 ERROR (MainThread) [pymyq.api] Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/token: 401 - Unauthorized
2023-08-04 10:04:41.901 WARNING (MainThread) [homeassistant.config_entries] Config entry XXXX@gmail.com' for myq integration not ready yet: Error requesting data from https://partner-identity.myq-cloud.com/connect/token: 401 - Unauthorized; Retrying in background

Additional information

I started noticing the problem in the 2023.7.X version before that I did not notice any problems.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 17 (6 by maintainers)

Most upvoted comments

OK… this sure looks like an issue with Home Assistant. MyQ working via app without issue. Had been working in Home Assistant without issue for months or more… maybe 18 months? Update to Home Assistant 2023.9.1 and it broke. Same unauthorized error in logs.

Following steps fixed issue for several days (until update to Home Assistant 2023.9.2).

docker exec -it homeassistant bash
cd /usr/local/lib/python3.11/site-packages/pymyq/
cp request.py request_bup.py
vi request.py
i to enter insert mode
Modify line 34
Was self._useragent = None
Is self._useragent = str("none")
Esc key to exit insert mode
:w + enter to write the changes
:x + enter to exit VI
Restart Home Assistant

After update to Home Assistant 2023.9.2 after restart MyQ not working (again). Didn’t even bother checking logs and just popped open ssh and executed the same steps (above) and restarted. MyQ now working as expected.

Line 34 in /usr/local/lib/python3.11/site-packages/pymyq/request.py appears to be the culprit. Did not check if it changed with Home Assistant 2023.9.1 or if something else changed resulting in line 34 becoming an issue? Does it matter?

There is enough discussion and detail confirming the change to line 34 fixes MyQ and persists (until Home Assistant update reverts the fix back to not working state).

What is the impact or risk to using the line 34 update going forward? Obviously someone closer to the code and with sufficient understanding of the entire code could weigh in on any non-obvious negative impact if line 34 in /usr/local/lib/python3.11/site-packages/pymyq/request.py is changed – but it seems like low hanging fruit and easy fix to big impact issue. (Big impact if you use MyQ for garage door).

Your issue is fixed in #100949. Please keep this issue clean.

I’m having this issue as well after upgrading from 2023.8.4 to 2023.9.3. I tried the workaround above and it worked for me as well. Does this fix need to be added to HA? I’m assuming this core integration is legit broken right now for everyone?

That case was closed because MyQ authentication started working again. Still want further investigation?

Ookla’s Down Detector shows hundreds of people taking the trouble to report an outage yesterday, which then cleared up…

image