jinnatar / python-cozify

Unofficial Cozify Python bindings and helpers
MIT License
16 stars 4 forks source link

Auth fail inside hub #6

Closed jinnatar closed 7 years ago

jinnatar commented 7 years ago

This shouldn't happen inside hub, should get escalated to cloud and either succeed or fail there.

Traceback (most recent call last): File "/srv/ephemeral/cozify-temp.git/cozify-single-sample.py", line 20, in main() File "/srv/ephemeral/cozify-temp.git/cozify-single-sample.py", line 9, in main data = hub.getDevices() File "/usr/local/lib/python3.5/dist-packages/cozify/hub.py", line 31, in getDevices raise APIError(response.status_code, response.text) cozify.Error.APIError: API error, 401: Authentication failed.

jinnatar commented 7 years ago

Thinking more about this, it's actually the naive implementation in cozify-single-sample.py and cozify-sample-loop.py that is to blame. The hub interface tries to be as lean as possible so it only triggers auth if it can easily be determined it is absolutely needed, for example if there is no token at all to use. In any case the v0.2.5 branch adds in more tools to take better care to keep the connection alive and happy. Eventually this may become more automated in v0.3 since it rewrites large chunks of the hub.