Skip to content

Improve auth handling - #53

Open
jenshorn wants to merge 3 commits into
masterfrom
improve-auth
Open

jenshorn wants to merge 3 commits into
masterfrom
improve-auth

Conversation

@jenshorn

Copy link
Copy Markdown
Collaborator

Reduce the number of login requests by persisting the token for reuse on further API requests. The same token is re-used until expiration and then a new token is requested using the refresh token instead of user/pass.

Also improved respect of 429 with backoff implemented.

@mattiasclaesson mattiasclaesson left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this change requires your poetry PR first to be checked ok?

@jenshorn
jenshorn force-pushed the improve-auth branch 2 times, most recently from c61a568 to f6394d2 Compare September 4, 2026 13:56
@jenshorn

jenshorn commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

I suppose this change requires your poetry PR first to be checked ok?

First of all sorry for the complete silence, it has been a busy year.
When I sat down to have a look at this again I felt the previous approach was a bit on the massive side, it is now rewritten and scaled down. The previously persisted authentication was to compensate for recreating the client, now we fix the lifecycle by retaining one client and keeping authentication in memory, removing disk persistence etc.

A corresponding ha-checkwatt change is being prepared. That includes a compatibility adapter for both pyCheckwatt 0.2.11 and this new API. With 0.2.11 it falls back to the existing behavior, once the updated pyCheckwatt is released the new features will be available.

Regarding the poetry PR; this is unrelated but I completed it as it was giving inconsistent results. Now each linter follow the same configuration and rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants