Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content

fix: resolve Notes app's synchronization fail issue with SSO

Description

If a user is logged in using OIDC for Murena account, the access token is only refreshed on CalDAV & CardDAV. The sync happens there either forcefully by user, or periodically in every ~15 minutes. The Notes app reuses the same token; it doesn't check or update the token.

In a corner case, when DAV syncs are not happening in the next 'X' minutes, but the token's Time-to-Live (TTL) is expired, and the user opens the Notes app at that time, then the API will return 401. To resolve this, we need to refresh the token before the notes API request is made.

Screenshots

Technical details

The AppAuth library in AccountManager uses a callback function to notify when the token refresh is done. But we want the request to be synchronous because the Notes app's request is synchronous. Hence, we had to rely on Kotlin's runBlocking() method to make the refresh() call blocking and synchronous.

Tests

Issues

https://gitlab.e.foundation/e/infra/backlog/-/issues/4085

10 commandments of code reviews

👪 ❤️ https://gitlab.e.foundation/internal/wiki/-/wikis/mobile-team/guidelines/Code-review

Edited by Fahim M. Choudhury

Merge request reports

Loading