vojtamolda / homebridge-ecobee3-sensors

Homebridge plugin that exposes Ecobee 3 sensors as HomeKit accessories.
https://www.npmjs.com/package/homebridge-ecobee3-sensors
MIT License
26 stars 15 forks source link

Regularly needing re-authorization #12

Closed DaveHamilton closed 7 years ago

DaveHamilton commented 7 years ago

Seems I'll get it working, authorize with Ecobee, and then after a few hours I get the "waiting for user to authorize application" message in the log again, complete with a new authorization code. Is this expected?

mrose17 commented 7 years ago

@DaveHamilton - it's not expected.

@vojtamolda - i see this as well, but only when doing development -- i have no idea why this happens!

mikeg1130 commented 7 years ago

I am also having this issue. At first, I thought it was only happening after a reboot the raspberrypi it is running on. But now I have had to re-authorize without any reboot occurring.

arkzrlo commented 7 years ago

Having this issue as well. I'm running homebridge as a systemd service as explained here: https://gist.github.com/johannrichard/0ad0de1feb6adb9eb61a/ if that's makes any difference.

vojtamolda commented 7 years ago

Hello everyone,

thanks for the comments here and I apologize for the problems. I never thought there would be real people actually using this code :smiley: Even less I hoped the people would care enough to open an issue...

As @mrose17 wrote the de-authorization is certainly not-intended and shouldn't happen. However, when I do development I sometimes get de-authorized too. It's typically caused by an interrupted authentication request-response. The new refreshed keys are not saved into the permanent storage untill the plugin recieves HTTP okay response from the ecobee server. If the interruption happens before the keys are stored, the next start-up tries to authorize with older (pre-refresh) keys and the ecobee server says Nono! Something's fishy here! and de-authorizes.

I've noticed that a particular application can be authorized only once for every user. For instance, I can't have two Homebridge servers (a stable version on my Raspberry Pi and the development version on my iMac) running with the plugin authorized on both machines. The first one will get immediately de-authorized once I authorize the second server.

Also, I'm personally having trouble reproducing this. I tried to let my Homebridge server run as a systemd service during my Christmas vacation and when I got back home after 3 weeks everything was perfect without any de-authorizations or any other problems. Could all of you, please, try to run Homebridge in debug mode like this:

homebridge -D

And then post the output here when the de-authorization happens? Running with -D will print the HTTP request/responses to/from ecobee servers and it will hopefully show the reason for de-authorization.

mrose17 commented 7 years ago

i think the issue is related to the interrupted authentication request-response. i don't think i've seen it happen when i didn't have a homebridge crash occur.

vojtamolda commented 7 years ago

Since people are no longer complaining, I assume the causes of the de-authorization were explained in my previous comment and I'm closing this bug. Or maybe this was one of the rare occasions where things magically fixed themselves 😃

Please feel free to re-open if the problems persist.