kmail/akonadi gmail imap - Session login cancelled

Hi, since an update to kmail/akonadi a month or so ago on TW/Plasma (in which login mechanism to gmail imap was updated) i have to repeatedly (every hour or so) restart akonadi due to login failure, the exact console message is:

Pass a valid window to KWallet::Wallet::openWallet(). QSslSocket::startClientEncryption: cannot start handshake on non-plain connection
org.kde.pim.kimap: Connection to server lost  0
org.kde.pim.imapresource: Session login cancelled

Thanks for any help

I should also mention that i have 2-factor authentication set up on gmail account. If anyone has a similar setup which does not display the same issue, that would be useful information.

I do. Added the Google account in systemsettings - online accounts. It opened an access window to Google, entered emailaddress, password en was asked for the Authenticator code. Done. But a customer reported the same issue. Before I could go there he reported that he had it working after trying a couple of times.

im very confused. I deleted all previous kmail/akonadi accounts and files. I then followed your suggestion and went to settings-online accounts. I set up a google account incl. verification. However the only options i have from this dialogue are youtube, hangouts and talk. I went back to kmail but looking at the account wizard setup, its just the same process as before with a separate authentication required. Could you explain how using settings-online accounts actually changes anything wrt kmail IMAP account?

Mmm, seeing the same. Quite sure though I added my Google account like this.
Try this: go around the account wizard ( shut it up ), then go Settings - kMail settings - Accounts and try to add the account from there.