Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

oauthutil: improved debug logs from token refresh

albertonyde8e9d469340
diff --git a/lib/oauthutil/oauthutil.go b/lib/oauthutil/oauthutil.go
index a44ae8028..d0a8edaae 100644
--- a/lib/oauthutil/oauthutil.go
+++ b/lib/oauthutil/oauthutil.go
@@ -250,9 +250,7 @@ func (ts *TokenSource) reReadToken() (changed bool) {
return false
}
- if !newToken.Valid() {
- fs.Debugf(ts.name, "Loaded invalid token from config file - ignoring")
- } else {
+ if newToken.Valid() {
fs.Debugf(ts.name, "Loaded fresh token from config file")
changed = true
}
@@ -264,6 +262,8 @@ func (ts *TokenSource) reReadToken() (changed bool) {
if changed {
ts.token = newToken
ts.tokenSource = nil // invalidate since we changed the token
+ } else {
+ fs.Debugf(ts.name, "No updated token found in the config file")
}
return changed
}
@@ -319,6 +319,8 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
return ts.token, nil
}
+ fs.Debug(ts.name, "Token expired")
+
// Try getting the token a few times
for i := 1; i <= maxTries; i++ {
// Try reading the token from the config file in case it has
@@ -344,6 +346,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
token, err = ts.tokenSource.Token()
if err == nil {
+ fs.Debug(ts.name, "Token refresh successful")
break
}
if newErr := maybeWrapOAuthError(err, ts.name); newErr != err {
diff --git a/lib/oauthutil/renew.go b/lib/oauthutil/renew.go
index 40eab7843..71357ebf5 100644
--- a/lib/oauthutil/renew.go
+++ b/lib/oauthutil/renew.go
@@ -47,16 +47,14 @@ func (r *Renew) renewOnExpiry() {
}
uploads := r.uploads.Load()
if uploads != 0 {
- fs.Debugf(r.name, "Token expired - %d uploads in progress - refreshing", uploads)
+ fs.Debugf(r.name, "Background refresher detected expired token - %d uploads in progress - refreshing", uploads)
// Do a transaction
err := r.run()
- if err == nil {
- fs.Debugf(r.name, "Token refresh successful")
- } else {
- fs.Errorf(r.name, "Token refresh failed: %v", err)
+ if err != nil {
+ fs.Errorf(r.name, "Background token refresher failed: %v", err)
}
} else {
- fs.Debugf(r.name, "Token expired but no uploads in progress - doing nothing")
+ fs.Debugf(r.name, "Background refresher detected expired token but no uploads in progress - doing nothing")
}
}
}