OAuth2: Refresh the token without aborting the sync
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 17 Oct 2018 12:49:00 +0000 (14:49 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:14 +0000 (10:58 +0100)
commit35967fc2d6cfe3fda3429b50b60296cfa3d663ec
tree9f3535fa3bafc765d78c124a25351060f27bb040
parent53a14c2041a66a7a312696b37913562e24f24efd
OAuth2: Refresh the token without aborting the sync

OAuth2 access token typically only has a token valid for 1 hour.
Before this patch, when the token was timing out during the sync, the
sync was aborted, and the ConnectionValidator was then requesting a new
token, so the sync can be started over.
If the discovery takes longer than the oauth2 validity, this means that
the sync can never proceed, as it would be always restarted from scratch.

With this patch, we try to transparently renew the OAuth2 token and restart
the jobs that failed because the access token was invalid.

Note that some changes were required in the GETFile job because it handled
the error itself and so it was erroring the jobs before its too late.

Issue #6814
src/libsync/abstractnetworkjob.cpp
src/libsync/abstractnetworkjob.h
src/libsync/creds/abstractcredentials.h
src/libsync/creds/httpcredentials.cpp
src/libsync/creds/httpcredentials.h
src/libsync/propagatedownload.cpp
src/libsync/propagatedownload.h