Bug 513064 - KMail should request new IMap Auth tokens if response denote as revoked
Summary: KMail should request new IMap Auth tokens if response denote as revoked
Status: REPORTED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: IMAP resource (other bugs)
Version First Reported In: 6.5.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-07 23:27 UTC by wheniwasatruestar
Modified: 2025-12-07 23:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wheniwasatruestar 2025-12-07 23:27:58 UTC
SUMMARY
After revoking email token within Google account, kmail/akonadictl does not make an effort to open a new auth request in the browser.

stdout from `akonadictl`:
```
org.kde.pim.kimap: sasl_client_step failed with: -1 "SASL(0): successful result: "
org.kde.kgapi: Bad request QUrl("https://accounts.google.com/o/oauth2/token?prettyPrint=false") , Google replied ' "{\n  \"error\": \"invalid_grant\",\n  \"error_description\": \"Token has been expired or revoked.\"\n}" '
```
I found this to be in a do-while loop of line 490 in loginjobs.cpp of the kimap repo (https://invent.kde.org/pim/kimap/-/blob/master/src/loginjob.cpp?ref_type=heads).

STEPS TO REPRODUCE
1. Link to gmail in kmail through new email or custom email (IMAP)
2. Somehow it doesn't create a new mail folder and says server unavailable in contrast to being able to connect to gmail, when it could years ago.
3. Remove the identity, recieving, sending of the failed-to-newly add account from kmail settings.
4. Go into accounts.google.com > Third-party apps & services. Revoke KDE's permissions.
5. Try to add gmail account to kmail again as in step 1.
6. Observe the stdout of akonadictl.

OBSERVED RESULT
"Failed to authenticate additional scopes" shows up in the kmail UI.
stdout from `akonadictl`:
```
org.kde.pim.kimap: sasl_client_step failed with: -1 "SASL(0): successful result: "
org.kde.kgapi: Bad request QUrl("https://accounts.google.com/o/oauth2/token?prettyPrint=false") , Google replied ' "{\n  \"error\": \"invalid_grant\",\n  \"error_description\": \"Token has been expired or revoked.\"\n}" '
```

EXPECTED RESULT
Kmail prompts for a new login with Google for the necessary (X)OAuth tokens by opening the browser, such  as Firefox.


SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.5.2
KDE Frameworks Version: 6.19.0
Qt Version: 6.10.0
Kernel Version: 6.17.8-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × 12th Gen Intel® Core™ i5-12400F
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: NVIDIA GeForce RTX 3060

ADDITIONAL INFORMATION
$ pacman -Qii akonadi akonadiconsole akonadi-calendar akonadi-contacts akonadi-import-wizard akonadi-mime akonadi-search kmail kmailtransport kmail-account-wizard libsasl | grep -
E "(Name|Version)"
Name            : akonadi
Version         : 25.08.3-1
Name            : akonadiconsole
Version         : 25.08.3-1
Name            : akonadi-calendar
Version         : 25.08.3-1
Name            : akonadi-contacts
Version         : 25.08.3-1
Name            : akonadi-import-wizard
Version         : 25.08.3-1
Name            : akonadi-mime
Version         : 25.08.3-1
Name            : akonadi-search
Version         : 25.08.3-1
Name            : kmail
Version         : 25.08.3-1
Name            : kmailtransport
Version         : 25.08.3-1
Name            : kmail-account-wizard
Version         : 25.08.3-1
Name            : libsasl
Version         : 2.1.28-5