Add Endurain sync backend#30
Conversation
|
Thanks for the Endurain backend — the mapping logic and the token-refresh handling look solid, and the test coverage on buildWeightRequest is appreciated. 👍 One thing I'd like changed before merging: the androidx.security:security-crypto dependency for token storage. Why:
So could you please drop the EncryptedSharedPreferences and store the tokens like everything else? |
|
Hi, thank you for the cosntructive feedback. I have updated the PR per your suggestions. Feel free to squash commits. |
* Merged `EndurainTokenManager` logic into `EndurainViewModel` and implemented a new `TokenStore` interface. * Updated `EndurainSync` to use the `TokenStore` interface, decoupling the sync wire layer from the Android ViewModel. * Replaced manual login state versioning with reactive `LiveData` (`loggedIn` and `refreshTokenExpiresAt`) for UI updates. * Improved thread safety for token updates by using `postValue` in the ViewModel. * Deleted the now-redundant `EndurainTokenManager` class.
|
Thanks I have refactored the token management into the ViewModel, could you please test it if it' still works? |
|
Thank you ! I retried a full login+sync flow with endurain and all works well. I think the work is now mergeable :-) |
|
Awesome, thanks! 👍 |
Push body weight + composition to a self-hosted Endurain server via
POST /api/v1/health/weight(upsert-by-date).Auth: OAuth2 username/password login -> JWT access + rotating refresh token, stored in EncryptedSharedPreferences (no password kept), with proactive refresh in
connect()and reactive refresh-on-401. MFA supported; SSO/PKCE deferred. Implemented clean-room from Endurain's REST API (not derived from Gadgetbridge's AGPL client).Field mapping reads openScale's generic, unit-aware values: masses (
muscle_mass/bone_mass) sent in kg, fat/water in %, plusvisceral_fat.bmiis left for the server to auto-calc;sourceis omitted (server enum rejects non-garmin). Export only.