Sync fails with no way to recover after token expires

Bug #1420002 reported by Alan Pope 🍺🐧🐱 πŸ¦„
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
High
Bill Filler
sync-monitor
Fix Released
High
Unassigned
signon-plugin-oauth2 (Ubuntu)
Fix Released
High
Alberto Mardegan
sync-monitor (Ubuntu)
Fix Released
High
Renato Araujo Oliveira Filho
sync-monitor (Ubuntu RTM)
New
High
Unassigned

Bug Description

I have two accounts on my krillin which I sync to google.
Opened calendar and hit 'sync' button. Navigated around a bit in the app, it died (will file separate bug for that) and I restarted it. Tried syncing again. Got a sync fail popup.

ubuntu-touch/ubuntu-rtm/14.09-proposed 231.

ProblemType: Bug
DistroRelease: Ubuntu RTM 14.09
Package: sync-monitor 0.1+15.04.20150127~rtm-0ubuntu1
Uname: Linux 3.4.67 armv7l
ApportVersion: 2.14.7-0ubuntu8
Architecture: armhf
Date: Mon Feb 9 21:11:51 2015
InstallationDate: Installed on 2015-02-09 (0 days ago)
InstallationMedia: Ubuntu Utopic Unicorn (development branch) - armhf (20150209-030204)
SourcePackage: sync-monitor
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Also attaching calendar log in case it's interesting...

Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

syncevolution log is ~4M

Bill Filler (bfiller)
Changed in sync-monitor (Ubuntu):
assignee: nobody → Renato Araujo Oliveira Filho (renatofilho)
importance: Undecided → High
tags: added: ww09
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

I believe this was caused due the online account token became invalid (has expired), we need to find a way to notify online-accounts about that. And request a new one.

Changed in ubuntu-system-settings-online-accounts:
importance: Undecided → High
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

I found the problem in fact this error was already documented in sync-monitor, this error can happen if the network became unstable during a sync.

The current solution is retry sync if this happen during a fast sync. But not after a slow sync.
But since this sync happen during the first sync and the first sync is always a slow sync, the sync-monitor did not try to re-sync it.

To solve this problem I change the code to retry the sync one more time even if the last sync was a slow sync or not.

Bill Filler (bfiller)
summary: - Sync fail 403 on krillin 231
+ Sync fails with no way to recover after token expires
Changed in sync-monitor:
importance: Undecided → High
Changed in sync-monitor (Ubuntu RTM):
importance: Undecided → High
Changed in canonical-devices-system-image:
importance: Undecided → High
Changed in sync-monitor:
status: New → In Progress
tags: added: calendar
Changed in canonical-devices-system-image:
milestone: none → ww09-2015
status: New → In Progress
Changed in canonical-devices-system-image:
assignee: nobody → Bill Filler (bfiller)
Revision history for this message
Alberto Mardegan (mardy) wrote :

I've been debugging the issue here, according to the steps (and the logs) which Renato provided me with.

So, a problem arises if the access token has expires and the refresh token (which can be used to request a new access token without UI interactions) is still valid, but the client application has been revoked access from https://myaccount.google.com/ (section "Connected apps and services"). In that case, here's the logs:

Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: oauth2plugin.cpp 111 OAuth2Plugin :
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: oauth2plugin.cpp 206 respondWithStoredToken : Stored token is expired
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: oauth2plugin.cpp 586 refreshOAuth2Token : "1/XXXX"
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: oauth2plugin.cpp 598 sendOAuth2PostRequest :
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: oauth2plugin.cpp 623 sendOAuth2PostRequest : Query string = QUrl( "?grant_type=refresh_token&refresh_token=1/XXXX&client_id=759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com&client_secret=juFngKUcuhB7IRQqHtSLavqJ" )
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: base-plugin.cpp 112 postRequest : Posting request: QUrl( "https://accounts.google.com/o/oauth2/token" )
Feb 13 15:02:15 ubuntu-phablet signonpluginprocess[13128]: ../../../../src/remotepluginprocess/remotepluginprocess.cpp 496 startTask operation is completed
Feb 13 15:02:16 ubuntu-phablet signonpluginprocess[13128]: base-plugin.cpp 152 handleNetworkError : error signal received: 302
Feb 13 15:02:16 ubuntu-phablet signonpluginprocess[13128]: base-plugin.cpp 167 handleNetworkError : Contents: "{#012 "error" : "invalid_grant",#012 "error_description" : "Token has been revoked."#012}"

So, this is a but in signon-plugin-oauth2, which should discard the refresh token and try the authentication again if some error happens while using the refresh token.

affects: ubuntu-system-settings-online-accounts → signon-plugin-oauth2 (Ubuntu)
Changed in signon-plugin-oauth2 (Ubuntu):
assignee: nobody → Alberto Mardegan (mardy)
status: New → In Progress
Changed in canonical-devices-system-image:
milestone: ww09-2015 → ww13-2015
Bill Filler (bfiller)
Changed in sync-monitor (Ubuntu):
status: New → Fix Released
Changed in sync-monitor:
status: In Progress → Fix Released
Changed in signon-plugin-oauth2 (Ubuntu):
status: In Progress → Fix Released
Changed in canonical-devices-system-image:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.