Remove dead Gmail OAuth code path #39

Closed
opened 2026-07-01 04:08:02 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 04:08:02 +00:00 (Migrated from github.com)

Context

The onboarding decision in #9 makes Gmail authenticate via an app password + preconfigured
IMAP/SMTP, not OAuth
. That leaves the Gmail OAuth implementation unused and unreachable:
nothing constructs an AuthType.OAUTH_GMAIL account (there is no addGmailAccount path and
no UI for it), so GmailAuthManager and the OAUTH_GMAIL branch can never run. This ticket
removes that dead code so the codebase matches the actual auth model.

Outlook keeps using OAuth via AppAuth — only the Gmail-specific OAuth path is removed.

Scope

  • Delete auth/GmailAuthManager.kt. Keep the shared OAuthResult / FreshToken types —
    the Outlook manager uses them.
  • Remove AuthType.OAUTH_GMAIL from domain/model/Account.kt and update every exhaustive
    when over AuthType. Confirm no persisted account rows use it (none can be created) and
    the Room authType mapper still round-trips.
  • In data/sync/MailConnectionFactory.kt: drop the gmailAuthManager injection, the
    AuthType.OAUTH_GMAIL -> branch in resolveSecret, and the SCOPE_GMAIL constant.
    Optionally simplify the useXoauth2 = authType != PASSWORD_IMAP logic now that Outlook is
    the only OAuth type.
  • In app/build.gradle.kts: remove gmailOAuthClientId, the GMAIL_OAUTH_CLIENT_ID and
    GMAIL_OAUTH_REDIRECT_URI BuildConfig fields, and the gmailRedirectScheme val.
  • AppAuth manifest placeholder — handle with care.
    manifestPlaceholders["appAuthRedirectScheme"] currently points at the Gmail scheme.
    AppAuth's bundled manifest requires this placeholder (manifest merge fails without it),
    so don't just delete it — repoint it to the Outlook scheme (org.libremail.outlook) or
    otherwise satisfy AppAuth, then re-verify the merged manifest. Update the explanatory
    comment on the RedirectUriReceiverActivity block in AndroidManifest.xml.
  • Remove GMAIL_OAUTH_CLIENT_ID from secrets.properties.example.
  • README Gmail-OAuth text is owned by #20 (whole README) / #31 (onboarding) — coordinate,
    don't duplicate the doc change here.

Acceptance criteria

  • No Gmail-OAuth references remain in code/build config (GmailAuthManager, OAUTH_GMAIL,
    GMAIL_OAUTH_*, SCOPE_GMAIL, gmailRedirectScheme).
  • :app:assembleDebug + :app:testDebugUnitTest + :app:lintDebug pass.
  • Outlook sign-in still works end-to-end (AppAuth redirect intact). This area has been
    fragile before (the AppCompat-theme redirect crash fix), so verify the merged manifest and a
    real Outlook login.

Relevant files

  • auth/GmailAuthManager.kt (delete), domain/model/Account.kt,
    data/sync/MailConnectionFactory.kt, app/build.gradle.kts,
    app/src/main/AndroidManifest.xml, secrets.properties.example

Dependencies

Follows the Gmail decision in #9 — can proceed independently now, since the path is already
unreachable. Coordinate the README with #20 / #31. Verify against the existing Outlook OAuth flow.

## Context The onboarding decision in #9 makes Gmail authenticate via an **app password + preconfigured IMAP/SMTP, not OAuth**. That leaves the Gmail OAuth implementation unused and unreachable: nothing constructs an `AuthType.OAUTH_GMAIL` account (there is no `addGmailAccount` path and no UI for it), so `GmailAuthManager` and the `OAUTH_GMAIL` branch can never run. This ticket removes that dead code so the codebase matches the actual auth model. **Outlook keeps using OAuth via AppAuth** — only the Gmail-specific OAuth path is removed. ## Scope - [ ] Delete `auth/GmailAuthManager.kt`. Keep the shared `OAuthResult` / `FreshToken` types — the Outlook manager uses them. - [ ] Remove `AuthType.OAUTH_GMAIL` from `domain/model/Account.kt` and update every exhaustive `when` over `AuthType`. Confirm no persisted account rows use it (none can be created) and the Room `authType` mapper still round-trips. - [ ] In `data/sync/MailConnectionFactory.kt`: drop the `gmailAuthManager` injection, the `AuthType.OAUTH_GMAIL ->` branch in `resolveSecret`, and the `SCOPE_GMAIL` constant. Optionally simplify the `useXoauth2 = authType != PASSWORD_IMAP` logic now that Outlook is the only OAuth type. - [ ] In `app/build.gradle.kts`: remove `gmailOAuthClientId`, the `GMAIL_OAUTH_CLIENT_ID` and `GMAIL_OAUTH_REDIRECT_URI` BuildConfig fields, and the `gmailRedirectScheme` val. - [ ] **AppAuth manifest placeholder — handle with care.** `manifestPlaceholders["appAuthRedirectScheme"]` currently points at the Gmail scheme. AppAuth's bundled manifest *requires* this placeholder (manifest merge fails without it), so don't just delete it — repoint it to the Outlook scheme (`org.libremail.outlook`) or otherwise satisfy AppAuth, then re-verify the merged manifest. Update the explanatory comment on the `RedirectUriReceiverActivity` block in `AndroidManifest.xml`. - [ ] Remove `GMAIL_OAUTH_CLIENT_ID` from `secrets.properties.example`. - [ ] README Gmail-OAuth text is owned by #20 (whole README) / #31 (onboarding) — coordinate, don't duplicate the doc change here. ## Acceptance criteria - No Gmail-OAuth references remain in code/build config (`GmailAuthManager`, `OAUTH_GMAIL`, `GMAIL_OAUTH_*`, `SCOPE_GMAIL`, `gmailRedirectScheme`). - `:app:assembleDebug` + `:app:testDebugUnitTest` + `:app:lintDebug` pass. - **Outlook sign-in still works end-to-end** (AppAuth redirect intact). This area has been fragile before (the AppCompat-theme redirect crash fix), so verify the merged manifest and a real Outlook login. ## Relevant files - `auth/GmailAuthManager.kt` (delete), `domain/model/Account.kt`, `data/sync/MailConnectionFactory.kt`, `app/build.gradle.kts`, `app/src/main/AndroidManifest.xml`, `secrets.properties.example` ## Dependencies Follows the Gmail decision in #9 — can proceed independently now, since the path is already unreachable. Coordinate the README with #20 / #31. Verify against the existing Outlook OAuth flow.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#39