Bug 391186 - [kio-gdrive]Access token expires/invalidates after performing a few file operations
Summary: [kio-gdrive]Access token expires/invalidates after performing a few file oper...
Status: CONFIRMED
Alias: None
Product: kio-gdrive
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 22.04.1
Platform: Archlinux Linux
: NOR major with 160 votes (vote)
Target Milestone: ---
Assignee: Elvis Angelaccio
URL:
Keywords:
: 381952 411653 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-02-27 22:56 UTC by Øystein Steffensen-Alværvik
Modified: 2022-11-26 11:15 UTC (History)
20 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Øystein Steffensen-Alværvik 2018-02-27 22:56:45 UTC
After a few minutes of successful use, Kio-gdrive suddenly refuses to open any file present on Drive. And when accessed from Dolphin→Networks→Google Drive→"Drive Account" gives "Unknown error".

Steps to reproduce: 

1) Authenticate a new account (System settings→Online accounts→Create→Google→Enter credentials and accept access)
2) Success notification pops up above system tray, with a nice button to Open the Drive folder
3) Press Open folder in the notification
4) Open a few files (I opened two-three PDF files)
5) The first files open successfully
6) When opening the third or so file, it opens with an error. Kio-gdrive stops working at all with the Drive account.

I saw from another report that the developer wanted the output of kdeinit5, so I ran kdeinit5 after I had authenticated the Google account but before kio-gdrive failed. Here's the output:

 kdeinit5: Got EXT_EXEC '/usr/bin/okular' from launcher.
kdeinit5: preparing to launch '/usr/bin/okular'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/gdrive.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/gdrive.so'
"userActionFinished error: 10"
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLYWVlbHNub3hEUEU?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi: KGAPI2::Drive::FileFetchJob(0x7ffc6f4ae5d0) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLYWVlbHNub3hEUEU?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi.raw: ""
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/http.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/http.so'
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLYWVlbHNub3hEUEU?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi: Status code:  401
org.kde.kgapi.raw: "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"authError\",\n    \"message\": \"Invalid Credentials\",\n    \"locationType\": \"header\",\n    \"location\": \"Authorization\"\n   }\n  ],\n  \"code\": 401,\n  \"message\": \"Invalid Credentials\"\n }\n}\n"
org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
org.kde.kgapi: 
kf5.kio.gdrive: virtual KGAPI2::AccountPtr KAccountsManager::refreshAccount(const AccountPtr&) not implemented.
kf5.kio.core: error() called twice! Please fix the "kio_gdrive" KIO slave
kdeinit5: PID 9738 terminated.
kdeinit5: PID 9754 terminated.
kdeinit5: PID 9732 terminated.
kdeinit5: PID 9737 terminated.
kdeinit5: Got EXT_EXEC '/usr/bin/gwenview' from launcher.
kdeinit5: preparing to launch '/usr/bin/gwenview'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/gdrive.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/gdrive.so'
"userActionFinished error: 10"
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi: KGAPI2::Drive::FileFetchJob(0x7ffc6f4ae600) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi.raw: ""
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/http.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/http.so'
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi: Status code:  401
org.kde.kgapi.raw: "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"authError\",\n    \"message\": \"Invalid Credentials\",\n    \"locationType\": \"header\",\n    \"location\": \"Authorization\"\n   }\n  ],\n  \"code\": 401,\n  \"message\": \"Invalid Credentials\"\n }\n}\n"
org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
org.kde.kgapi: 
kf5.kio.gdrive: virtual KGAPI2::AccountPtr KAccountsManager::refreshAccount(const AccountPtr&) not implemented.
kf5.kio.core: error() called twice! Please fix the "kio_gdrive" KIO slave
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffc6f4ae080) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi.raw: ""
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Status code:  401
org.kde.kgapi.raw: "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"authError\",\n    \"message\": \"Invalid Credentials\",\n    \"locationType\": \"header\",\n    \"location\": \"Authorization\"\n   }\n  ],\n  \"code\": 401,\n  \"message\": \"Invalid Credentials\"\n }\n}\n"
org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
org.kde.kgapi: 
kf5.kio.gdrive: virtual KGAPI2::AccountPtr KAccountsManager::refreshAccount(const AccountPtr&) not implemented.
kf5.kio.core: error() called twice! Please fix the "kio_gdrive" KIO slave
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi: KGAPI2::Drive::FileFetchJob(0x7ffc6f4ae600) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi.raw: ""
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8")
org.kde.kgapi: Status code:  401
org.kde.kgapi.raw: "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"authError\",\n    \"message\": \"Invalid Credentials\",\n    \"locationType\": \"header\",\n    \"location\": \"Authorization\"\n   }\n  ],\n  \"code\": 401,\n  \"message\": \"Invalid Credentials\"\n }\n}\n"
org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
org.kde.kgapi: 
kf5.kio.gdrive: virtual KGAPI2::AccountPtr KAccountsManager::refreshAccount(const AccountPtr&) not implemented.
kf5.kio.core: error() called twice! Please fix the "kio_gdrive" KIO slave
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi: KGAPI2::Drive::FileFetchJob(0x7ffc6f4ae5d0) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi.raw: ""
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/files/0B5Ns9h6gbAsLbzRYdnBUMkZUNm8?fields=kind,id,mimeType,downloadUrl,exportLinks")
org.kde.kgapi: Status code:  401
org.kde.kgapi.raw: "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"authError\",\n    \"message\": \"Invalid Credentials\",\n    \"locationType\": \"header\",\n    \"location\": \"Authorization\"\n   }\n  ],\n  \"code\": 401,\n  \"message\": \"Invalid Credentials\"\n }\n}\n"
org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
org.kde.kgapi: 
kf5.kio.gdrive: virtual KGAPI2::AccountPtr KAccountsManager::refreshAccount(const AccountPtr&) not implemented.
kf5.kio.core: error() called twice! Please fix the "kio_gdrive" KIO slave
kdeinit5: PID 9763 terminated.
kdeinit5: PID 9767 terminated.
kdeinit5: PID 9776 terminated.
Comment 1 Øystein Steffensen-Alværvik 2018-02-27 22:58:09 UTC
kio-gdrive 1.2.1-0neon+16.04+xenial+build22 amd64
Neon 5.12.2
Frameworks 5.43.0
Qt 5.10.0
Comment 2 Elvis Angelaccio 2018-08-26 17:41:26 UTC
Confirmed, sorry for taking so long.

The problem seems to (randomly) happen when communicating with signond. As result we get empty access/refresh tokens from KAccounts, which causes the "Unknown error" from the gdrive slave.

Relevant logs:

ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 61 createAuthSession
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 35 SignonAuthSession
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 42 SignonAuthSession "/com/google/code/AccountsSSO/SingleSignOn/AuthSession_2"
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 70 createAuthSession SignonAuthSession created successfully: "/com/google/code/AccountsSSO/SingleSignOn/AuthSession_2"
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: 12158 exitStatus= 0
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: found no pending requests for PID 12158
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsessionadaptor.cpp 76 process "web_server"
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 142 id
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 142 id
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 1373 credentials id: 143 queryPassword: false
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 149 method
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 913 startNewRequest Starting the authentication process
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 316 startProcess the number of requests is 1
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 1373 credentials id: 143 queryPassword: true
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 1379 credentials Loading credentials from DB.
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 1391 credentials Password is empty
ago 26 18:03:42 arch-x220 signond[12137]: accesscontrolmanagerhelper.cpp 167 isPeerAllowedToAccess "*"
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 1465 loadData Loading: 143 , "oauth2"
ago 26 18:03:42 arch-x220 signond[12137]: credentialsdb.cpp 702 methodId method: "oauth2"
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 136 stateChangedSlot
ago 26 18:03:42 arch-x220 signond[12137]: signonauthsession.cpp 136 stateChangedSlot
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: remotepluginprocess.cpp 234 error error is sent 2   "Failed to I/O session data to/from the signon daemon."
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: remotepluginprocess.cpp 419 startTask operation is completed
ago 26 18:03:42 arch-x220 kdeinit5[12172]: "Failed to I/O session data to/from the signon daemon."
ago 26 18:03:42 arch-x220 signond[12137]: pluginproxy.cpp 307 onReadStandardOutput PROXY RESULT OPERATION: 3
ago 26 18:03:42 arch-x220 signond[12137]: pluginproxy.cpp 344 handlePluginResponse 3
ago 26 18:03:42 arch-x220 kdeinit5[12172]: kf5.kio.gdrive: KIO GDrive ready: version 1.2.4
ago 26 18:03:42 arch-x220 signond[12137]: pluginproxy.cpp 409 handlePluginResponse PLUGIN_RESPONSE_ERROR
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 772 processError
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 397 replyError Deprecated error code: 2
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: Operation requested while plugin busy! - code 14
ago 26 18:03:42 arch-x220 signond[12137]: signonsessioncore.cpp 896 startNewRequest No more requests to process
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: 12168 exitStatus= 0
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: found no pending requests for PID 12168
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: plugin.cpp 49 ~Plugin :
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: oauth2plugin.cpp 115 ~OAuth2Plugin :
ago 26 18:03:42 arch-x220 signonpluginprocess[12164]: oauth2plugin.cpp 91 ~OAuth2PluginPrivate :
ago 26 18:03:42 arch-x220 signond[12137]: pluginproxy.cpp 453 onExit Plugin process exit with code  0  :  QProcess::ExitStatus(NormalExit)
ago 26 18:03:42 arch-x220 kdeinit5[12172]: kf5.kio.gdrive: Running job KGAPI2::Drive::AboutFetchJob(0x7ffc07083170) with accessToken ""
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffc07083170) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: KLauncher: launching new slave "/usr/lib/qt/plugins/kf5/kio/http.so" with protocol= "https" args= ("https", "local:/run/user/1000/klauncherkCJMoO.1.slave-socket", "local:/run>
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: Asking kdeinit to start "/usr/lib/qt/plugins/kf5/kio/http.so" ("https", "local:/run/user/1000/klauncherkCJMoO.1.slave-socket", "local:/run/user/1000/kio_gdriveNEpeAE.2.slave->
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: "/usr/lib/qt/plugins/kf5/kio/http.so" (pid 12179) up and running.
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: removing done request "/usr/lib/qt/plugins/kf5/kio/http.so" PID 12179
ago 26 18:03:42 arch-x220 klauncher[1289]: kf5.kinit.klauncher: new app ":1.665"
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi: Status code:  401
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi: Unauthorized. Access token has expired or is invalid.
ago 26 18:03:42 arch-x220 kdeinit5[12172]: org.kde.kgapi:
ago 26 18:03:42 arch-x220 kdeinit5[12172]: kf5.kio.gdrive: Job status code: 401 - message: "Invalid authentication."
Comment 3 Elvis Angelaccio 2018-09-02 15:05:00 UTC
*** Bug 381952 has been marked as a duplicate of this bug. ***
Comment 4 Cristiano Furtado 2019-06-26 13:38:54 UTC
a soluction to fedora 30, install package rawhide.

with root or sudo:
dnf install https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/k/kio-gdrive-1.2.6-2.fc31.x86_64.rpm

after: dbus-launch dolphin or reboot
Comment 5 Elvis Angelaccio 2019-09-09 22:53:14 UTC
*** Bug 411653 has been marked as a duplicate of this bug. ***
Comment 6 Angelos Skembris 2019-09-11 11:47:07 UTC
Getting the same error in Dolphin 19.08 / kio-gdrive 1.2.7. 

With 1.2.6, I managed to access the drive once or twice before failure, now it doesn't manage to access it even once.
Comment 7 Eugene 2019-11-24 17:00:55 UTC
The same on my Kubuntu 19.10 x86_64
Plasma: 5.17.3
KDE Frameworks: 5.64.0
QT: 5.12.4
Comment 8 Varaskkar 2019-11-24 17:07:52 UTC
Me too:

Plasma: 5.17.3
QT: 5.13.2
KDE Frameworks: 5.64.0
OS: Manjaro 18.1.3 Juhraya                
Kernel: x86_64 Linux 5.4.0-1-MANJARO      
CPU: Intel Core i7-8565U @ 8x 4.6GHz
GPU: Mesa DRI Intel(R) UHD Graphics
RAM: 4660MiB / 15726MiB
Comment 9 Piotr Martycz 2020-05-16 08:40:35 UTC
So if access tokens are time limited what component is responsible for their refreshing? Can we trigger it manually?
Comment 10 Elvis Angelaccio 2022-09-15 22:29:17 UTC
Git commit 3db025102b89e96f74a7d8ff68147cd6649df100 by Elvis Angelaccio.
Committed on 15/09/2022 at 22:11.
Pushed by elvisangelaccio into branch 'master'.

Don't start runJob() loop if the access token is not available.

Otherwise the loop will go on forever, attempting to start jobs that
will never work.

KAccounts seems to return an empty access token when google returns
a 401 error (access code expired).

M  +3    -0    src/gdrivehelper.cpp
M  +3    -0    src/kaccountsmanager.cpp
M  +8    -1    src/kio_gdrive.cpp

https://invent.kde.org/network/kio-gdrive/commit/3db025102b89e96f74a7d8ff68147cd6649df100
Comment 11 Elvis Angelaccio 2022-09-15 22:30:35 UTC
I just pushed a fix for another issue cause by expired tokens, but this probably still doesn't fix the original issue reported here.
Comment 12 firewalker 2022-11-26 11:15:08 UTC
Still happens to me on Archlinux.