fix(email): test saved OAuth accounts through shared transports#5653
Open
RaresKeY wants to merge 3 commits into
Open
fix(email): test saved OAuth accounts through shared transports#5653RaresKeY wants to merge 3 commits into
RaresKeY wants to merge 3 commits into
Conversation
The test-connection endpoint was password-only and had no awareness of
OAuth accounts. For Google-connected accounts this caused two failures:
- IMAP: "Need IMAP host, username, and password" because imap_pass is
empty (no password is stored for OAuth accounts)
- SMTP: 535 BadCredentials because smtp.login() was called with an
empty password instead of an XOAUTH2 token
Fix: include oauth_provider and token fields in saved_body when hydrating
from the DB, then use conn.authenticate("XOAUTH2") / smtp.auth("XOAUTH2")
for Google accounts in both the IMAP and SMTP test paths, mirroring what
_send_smtp_message already does for real sends.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the XOAUTH2 changes made to routes/email_routes.py:
- Google OAuth accounts must not be rejected with 'Need IMAP host,
username, and password' (no stored password for OAuth accounts)
- IMAP and SMTP test paths must use conn.authenticate('XOAUTH2')
for Google accounts
- Password accounts must still use conn.login() / smtp.login()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
RaresKeY
marked this pull request as ready for review
July 21, 2026 12:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Let the saved-account Test connection action authenticate Google OAuth
accounts without requiring stored IMAP/SMTP passwords. The route resolves
OAuth only from the owner-checked saved row, keeps inline form values on the
password path, and reports the real IMAP and SMTP results independently.
This replacement preserves TNTBA's two focused commits from #5021 and keeps
the current-
devowner and authentication updates in a separate maintainer commit.Related implementation
Supersedes #5021 on current
devwhile preserving its original authored commits.Target branch
dev, notmain.Linked Issue
Fixes #5644
Part of #5637
Type of Change
Checklist
dev.How to Test
Run:
Save a Google OAuth account with no IMAP/SMTP password and run Test connection.
Verify IMAP and SMTP each use the saved account identity and report success independently.
Repeat with a password account and verify its login behavior is unchanged.
Fresh current-
devreview passes 137 broader email/IMAP/SMTP tests and Python compilation. Diff checks pass. Live-provider validation remains a reviewer item.Visual / UI changes
N/A — backend connection testing and tests only; no UI rendering changed.
Screenshots / clips
N/A — no visual changes.