1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 02:23:24 +00:00

oauthutil: read a fresh token config file before using the refresh token.

This means that rclone will pick up tokens from concurrently running
rclones.  This helps for Box which only allows each refresh token to
be used once.

Without this fix, rclone caches the refresh token at the start of the
run, then when the token expires the refresh token may have been used
already by a concurrently running rclone.

This also will retry the oauth up to 5 times at 1 second intervals.

See: https://forum.rclone.org/t/box-token-refresh-timing/8175
This commit is contained in:
Nick Craig-Wood
2019-01-04 18:06:46 +00:00
parent b8280521a5
commit 2d01a65e36
2 changed files with 63 additions and 6 deletions

View File

@@ -575,6 +575,17 @@ func SetValueAndSave(name, key, value string) (err error) {
return nil
}
// FileGetFresh reads the config key under section return the value or
// an error if the config file was not found or that value couldn't be
// read.
func FileGetFresh(section, key string) (value string, err error) {
reloadedConfigFile, err := loadConfigFile()
if err != nil {
return "", err
}
return reloadedConfigFile.GetValue(section, key)
}
// ShowRemotes shows an overview of the config file
func ShowRemotes() {
remotes := getConfigData().GetSectionList()