Bug 434508

Summary: Cannot login to Google when adding Google calendar
Product: [Frameworks and Libraries] Akonadi Reporter: aslam karachiwala <4slam>
Component: Google ResourceAssignee: Daniel Vrátil <dvratil>
Status: RESOLVED FIXED    
Severity: major CC: 4slam, dvratil, kdepim-bugs, tomastrnka
Priority: NOR    
Version: 5.13.3   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Error when trying to login to Google in order to add Google calendar

Description aslam karachiwala 2021-03-16 18:53:16 UTC
Created attachment 136747 [details]
Error when trying to login to Google in order to add Google calendar

SUMMARY
Google login attempt cannot proceed when trying to add calendar(s) in a Google account.

STEPS TO REPRODUCE
1. Menu: Settings > Configure KOrganizer...
2. In the Configure window, General > Calendars > Add... button
3. Select 'Google Calendars & Tasks'
4. Click Add... button under Accounts in the Google Calendar... config window
5. A window opens showing 'Akonadi Resources for Google Services'
6. Enter email address corresponding to the Google account as instructed, and click Next

OBSERVED RESULT
Google login interface/window shows "Window shows "Couldn’t sign you in."

EXPECTED RESULT
Google login interface should allow login with the correct credentials.

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8

ADDITIONAL INFORMATION
Screenshot of error attached.
Comment 1 Tomas Trnka 2021-03-22 13:24:22 UTC
I just stumbled upon this same issue. I guess it might be related to Google's ongoing crackdown against using embedded webviews for authentication:

https://security.googleblog.com/2019/04/better-protection-against-man-in-middle.html
https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html

The official recommended way to handle authentication is to open a full-blown browser so that people can reuse signed-in accounts and stored passwords. I suppose KGAPI will need to be adjusted to launch a browser. Until that happens, you can do it manually as a workaround:

Steps:
1.-4. See above.
5. A window opens asking you to sign in to Google. Select and copy the full URL in the address bar of this window. Leave the window open but do not interact with it further.
6. Open a new tab in your favourite browser. Paste the URL copied in Step 5 to the address bar and navigate to it.
7. A page opens asking you to sign in to Google. Sign in and confirm granting necessary permissions to Akonadi.
8. Your main browser should now be redirected to a blank page at 127.0.0.1:some_random_port_number. This passes the authentication tokens to Akonadi behind the scenes. The Akonadi sign-in window opened in Step 5 should now automatically disappear. Once that happens, you can close this blank tab in your main browser.
Comment 2 aslam karachiwala 2021-03-22 21:28:41 UTC
(In reply to Tomas Trnka from comment #1)
Confirming this workaround. Thx!
Comment 3 Daniel Vrátil 2023-04-22 06:24:40 UTC
We have since moved to browser-based authentication so users should no longer see this warning as long as they use a reasonably up-to-date browser.