thomasmunduchira / myq-api

An updated API to interface with myQ devices
https://www.npmjs.com/package/myq-api
MIT License
137 stars 38 forks source link

ERR_MYQ_INVALID_SERVICE_RESPONSE recently started appearing #46

Open julianh2o opened 3 years ago

julianh2o commented 3 years ago

Hey Thomas,

I've been using this library to control my garage door opener for awhile now and it's been working pretty well. However, recently I've started getting the dreaded ERR_MYQ_INVALID_SERVICE_RESPONSE error. Do you have any advice on how to further troubleshoot this? I'm happy to try to contribute a fix if it turns out there's been a small tweak in the API, but some guidance would be much appreciated.

Relevant snippet: (using express)

    const myq = new MyQ();
    try {
        await myq.login(myq_credentials.username,myq_credentials.password);
        const state = await myq.getDoorState(garage_door);
        res.send(state);
    } catch (err) {
        res.send(err);
    }

Error response:

{
  "name": "MyQError",
  "code": "ERR_MYQ_INVALID_SERVICE_RESPONSE",
  "_serviceError": {
    "message": "Request failed with status code 400",
    "name": "Error",
    "stack": "Error: Request failed with status code 400\n    at createError (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/home/julian/blinds/node_modules/myq-api/node_modules/axios/lib/adapters/http.js:260:11)\n    at emitNone (events.js:111:20)\n    at IncomingMessage.emit (events.js:208:7)\n    at endReadableNT (_stream_readable.js:1064:12)\n    at _combinedTickCallback (internal/process/next_tick.js:138:11)\n    at process._tickCallback (internal/process/next_tick.js:180:9)",
    "config": {
      "url": "Login",
      "method": "post",
      "data": "{\"Username\":\"jul***@gmail.com\",\"Password\":\"******\"}",
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/json",
        "MyQApplicationId": "JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu",
        "ApiVersion": "5.2",
        "BrandId": "2",
        "Culture": "en",
        "User-Agent": "3d599e2ae7215f47fb49",
        "Content-Length": 56
      },
      "baseURL": "https://api.myqdevice.com/api/v5",
      "transformRequest": [
        null
      ],
      "transformResponse": [
        null
      ],
      "timeout": 0,
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      "maxContentLength": -1,
      "maxBodyLength": -1
    }
  }
}
simmonyau commented 3 years ago

You might want to update your post to remove your username/password. I'm getting the same error as well and I believe others have commented that it's due to a switch from MY Q developers to api v6 which apparently makes use of an oauth token. Not sure if anyone is actively looking at this though.

julianh2o commented 3 years ago

You might want to update your post to remove your username/password. I'm getting the same error as well and I believe others have commented that it's due to a switch from MY Q developers to api v6 which apparently makes use of an oauth token. Not sure if anyone is actively looking at this though.

Thanks! Oops :)

brbeaird commented 3 years ago

It appears MyQ has disabled the v5 API, which is unfortunate but was inevitable. There is a v6 available, but moving over to it is not exactly a simple process.

simmonyau commented 3 years ago

That's exactly why I bought a relay switch to bypass third party APIs. Got to do what I can to increase the stability of my home automation.

nsnyder commented 3 years ago

This is a duplicate of #34. I might try to pull together a PR for V6 when I get some free time, but I'm pretty busy right now.

koush commented 3 years ago

You might want to update your post to remove your username/password. I'm getting the same error as well and I believe others have commented that it's due to a switch from MY Q developers to api v6 which apparently makes use of an oauth token. Not sure if anyone is actively looking at this though.

Thanks! Oops :)

Editing does not scrub the history of the comment which is still visible. Change your password.

julianh2o commented 3 years ago

Editing does not scrub the history of the comment which is still visible. Change your password.

Thank you! Already done, the editing was just to bury my careless blunder ;)

koush commented 3 years ago

I stripped down the MyQ API in Homebridge (https://github.com/hjdhjd/homebridge-myq) into a standalone here:

https://github.com/koush/myq

npm install --save @koush/myq

Works well.

thomasmunduchira commented 3 years ago

Hey folks, I'm taking a look at this now. It appears that we need to migrate to the v6 API (tracked in #34) in order to mitigate this. I'm not sure how feasible implementing the new authentication flow is, but I'll take a look at the related projects that have already migrated and see if I can pattern match.

See #34 for future updates. Just a heads up that this won't be an overnight fix, and might take week(s) in order to land v6 support. I appreciate your patience regarding this :)

cjustinhall commented 3 years ago

I stripped down the MyQ API in Homebridge (https://github.com/hjdhjd/homebridge-myq) into a standalone here:

https://github.com/koush/myq

npm install --save @koush/myq

Works well.

Has anybody tried this? Have you found it successful w the v6 api?

koush commented 3 years ago

Yes it works with the v6 API.

skykep commented 3 years ago

How are you running it as a standalone? I've installed it but missing the point of execution.