pnbruckner / life360

A simple python life360 client
MIT License
16 stars 6 forks source link

Reorganize API & add more error handling #16

Closed pnbruckner closed 2 months ago

pnbruckner commented 2 months ago

Earlier this year Life360 (via Cloudflare) seemed to take positive steps to block their API from unauthorized usage. However, recently there have been reports that the HA Life360 integration just magically started working again for some people.

After some experimenting, it seems the server API does work again. However, there is one major difference, which is that the "Circles URL" seems to cause an HTTP Error 429 (too many requests) very often. So, this PR adds some more error handling, especially for error 429, which returns the value from the "retry-after" response header, so that the user (the HA integration) can delay and try the request again.

The package's API has also been changed to simplify based on the main use case (the HA integration.)

Additional redactions have been implemented, with an optional "verbosity" parameter in the Life360 constructor, that allows the user to specify how much debug info should be written to the log and how much redaction should be done.

Lastly, some functionality has been removed, but may be added again later.