arraylabs / pymyq

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

Another API issue (2021/02/22)? #84

Closed luisiam closed 3 years ago

luisiam commented 3 years ago

MyQ stopped working again. Running Home Assistant 2021.2.3 on docker. Error is observed in the log.

Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/token: 400 - Bad Request

dseven commented 3 years ago

It appears we're being blocked on user-agent again. Changing it to something made-up (i.e. not "null") makes it work again. Ho hum....

luisiam commented 3 years ago

I thought V6 API will be fixing this issue.

dseven commented 3 years ago

V6 can't fix them blocking us based on user-agent.

luisiam commented 3 years ago

Thanks for the tips. Changed the user-agent and it's working again.

ds7771 commented 3 years ago

Same here. Changed user agent to "pymyq" and its authenticating again.

jhernandfl commented 3 years ago

It's almost comical, the game of cat & mouse. Is there a practical case for setting user-agent to mimic that of a blessed client?

dseven commented 3 years ago

It's almost comical, the game of cat & mouse. Is there a practical case for setting user-agent to mimic that of a blessed client?

We've been down that road, and many others............

broyuken commented 3 years ago

I set it to pymyq and I'm still not able to authenticate.

2021-02-22 18:41:05 ERROR (MainThread) [pymyq.api] Authentication failed: Error requesting data from https://partner-identity.myq-cloud.com/connect/token: 400 - Bad Request
squirtbrnr commented 3 years ago

I knew how to change the default agent in v2 of pymyq. how does one go about changing it in v3? Line 384 and 401 of api.py?

dseven commented 3 years ago

I knew how to change the default agent in v2 of pymyq. how does one go about changing it in v3? Line 384 and 401 of api.py?

That's what worked for me.

dseven commented 3 years ago

... or the just-released 3.0.4 - thanks @ehendrix23 !

DEBUG:pymyq.api:No user agent provided, trying to retrieve from GitHub.
DEBUG:pymyq.api:Retrieved user agent #RANDOM:5 from GitHub.
DEBUG:pymyq.api:User agent set to randomized value: FpicQ.

Would be amusing if it randomly generated "FUmyQ" 🤣

ehendrix23 commented 3 years ago

And @dseven was a bit too quick for me. :-)

I re-introduced the User Agent logic in pymyq 3.0.4. The MyQ is HACS has been updated as well (v0.0.4) (Note that the pre-release for light switches has not yet been updated, most likely tomorrow).

broyuken commented 3 years ago

I knew how to change the default agent in v2 of pymyq. how does one go about changing it in v3? Line 384 and 401 of api.py?

That did it. I only changed it on 384. Didn’t realize it was in 2 spots.