Closed hgoscenski closed 8 months ago
So you think we need to add that back in? I wish I knew all the response returns. @tnoor-co Could you help any with that?
@jfarmer08 I do, my instance was unable to control any accessories and was getting the above message.
The way we are handling recovery from the login failure was via catching the exception, it appears that the Wyze API does not return a failing HTTP code, but rather a 200 OK with a msg/code inside of it.
Looking at the logs I believe that code == 1
indicates success.
I pushed version 1.1.4
@hgoscenski Do you mind if I direct message you?
@hgoscenski looks like result.data.code is null every time. Not sure what is the best way to fix. this.
Interesting, we could potentially do this:
if (result.data.code && result.data.code != 1)
That does work.
@tnoor-co Could you help any with that?
Hey @jfarmer08 - sorry I was a bit swamped today. I did get some time to work on it and was able to gather some error codes and messages we could match on, and then went down a rabbit hole. I initially hoped Wyze was using JWT's, so we could attempt to extract the expiration from it, but the tokens were encrypted - so y'alls current solution of estimating is the most optimal one. I then came across rate limiting headers and added some handling there along with retrying the requests selectively. There were a decent amount of changes made on it that may not be fully on topic here - so apologies in advance for it. Happy to collaborate on it further if you're open to it. https://github.com/jfarmer08/wyze-api/pull/12
@tnoor-co Thank you for the help with this. I did make a couple of changes, since there were some unexpected ending and the code would not compile. I will do some testing with this, but so far it looks good after the changes.
I am liking the pull request now. Although I think it needs more testing. Within the next few days I will make a release.
After token expires, it appears that without checking the code/msg of the response the
wyze-api
is not attempting to refresh the token.