-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receiving 403 from https://accounts.myq-cloud.com/api/v6.0/accounts #184
Comments
I'm having the same issue, and it started around the same time. Seems like something changed on the MyQ API end. |
MyQ implemented CloudFlare, and now a particular User Agent is required in the header of some of the requests during login. There's some good debugging over here: home-assistant/core#99947 |
@vincebel8 Thanks for that! I looked over that thread and it seems like the folks there were having good luck with setting the Enabling debug logging, I can see that it's using a random string for Thanks. |
@jonheese is this the fork you tried? https://github.com/Lash-L/pymyq/tree/useragent_fix |
@vincebel8 Yes, I used the zip file from that fork, but I assume it's the same code. |
The bug is on line 124 of request. py. the 429 status returns a header named "retry-after". That field specifies the number of seconds the Client must wait before trying again. Instead, the code on line 124 tries to do exponential back-off, but it starts from a very small value. If you look at the error header, you will see the server is asking for a wait time of 1750 Seconds or more. See this link: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After This explains why shutting down the module and waiting seems to fix the problem. And it explains why the problem is intermittent: it is happening on the Oauth auth cycle, which is somewhat infrequent. The stuff about user agent strings is a red herring. |
@ehendrix23 please see above |
I will also note that the exponential backoff as implemented is broken. The wait time is computed as the min() of 2 raised to the power of the attempt number , or 5. So, as successive attempts unfold, the wait times will be: 2 And so on. What was meant was probably max(2**attempt, 5). That might actually work, even though it's not correct behavior in the face of a 429 error. |
I recently had to switch out my router which gave all new IPs to my entire network, not sure if this is part of the problem, but this is when the issue started occurring. I deleted the MyQ integration, rebooted HA, then re-added, but I still get the same error. I use the same exact credentials to login to the MyQ app on my Android, so I'm not understanding why it's giving me a 403. Is there something else I need to do? I added logging to the myq component in HA to write out the credentials and those are getting passed in correctly to:
yet a MyQError is getting thrown, this is what I logged:
ERROR (MainThread) [homeassistant.components.myq] async_setup_entry, Failed to login due to(MyQError): Error requesting data from https://accounts.myq-cloud.com/api/v6.0/accounts: 403 - Forbidden
Any help is appreciated.
The text was updated successfully, but these errors were encountered: