jinnatar/python-cozify

Hub token can expire and not get auto-renewed even though cloud is still valid

Closed this issue · 1 comments

Hub token can expire and not get auto-renewed even though cloud is still valid.
hub.ping() will fail:

hub.ping()
WARNING:root:API error, 401: Unauthorized - http://10.0.10.147:8893/cc/1.8/hub/tz - Authentication failed.
False

.. but cloud.ping() succeed:

cloud.ping()
True

Easily fixed if you know what to do:

cloud.authenticate()
WARNING:root:API error, 401: Unauthorized - http://10.0.10.147:8893/cc/1.8/hub/tz - Authentication failed.
True
hub.ping()
True

So this needs to get detected in hub.ping() and handled gracefully by renewing the hub token.

Handling improved in devel to autorenew an expired hub_token by default on a hub.ping() call. Since cloud_tokens are kept up to date there's no reason to pre-emptively renew hub_tokens until they fail.

Will end up released in v0.2.14 at a later point in time. As a workaround just run cloud.authenticate() to renew an expired hub_token.