mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 00:13:49 +01:00
zoho: print clear error message when missing oauth scope
This commit is contained in:
parent
c172742cef
commit
f4deffdc96
@ -37,7 +37,7 @@ const (
|
|||||||
rcloneClientID = "1000.46MXF275FM2XV7QCHX5A7K3LGME66B"
|
rcloneClientID = "1000.46MXF275FM2XV7QCHX5A7K3LGME66B"
|
||||||
rcloneEncryptedClientSecret = "U-2gxclZQBcOG9NPhjiXAhj-f0uQ137D0zar8YyNHXHkQZlTeSpIOQfmCb4oSpvosJp_SJLXmLLeUA"
|
rcloneEncryptedClientSecret = "U-2gxclZQBcOG9NPhjiXAhj-f0uQ137D0zar8YyNHXHkQZlTeSpIOQfmCb4oSpvosJp_SJLXmLLeUA"
|
||||||
minSleep = 10 * time.Millisecond
|
minSleep = 10 * time.Millisecond
|
||||||
maxSleep = 2 * time.Second
|
maxSleep = 60 * time.Second
|
||||||
decayConstant = 2 // bigger for slower decay, exponential
|
decayConstant = 2 // bigger for slower decay, exponential
|
||||||
configRootID = "root_folder_id"
|
configRootID = "root_folder_id"
|
||||||
)
|
)
|
||||||
@ -83,7 +83,7 @@ func init() {
|
|||||||
getSrvs := func() (authSrv, apiSrv *rest.Client, err error) {
|
getSrvs := func() (authSrv, apiSrv *rest.Client, err error) {
|
||||||
oAuthClient, _, err := oauthutil.NewClient(ctx, name, m, oauthConfig)
|
oAuthClient, _, err := oauthutil.NewClient(ctx, name, m, oauthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to load oAuthClient: %w", err)
|
return nil, nil, fmt.Errorf("failed to load OAuth client: %w", err)
|
||||||
}
|
}
|
||||||
authSrv = rest.NewClient(oAuthClient).SetRoot(accountsURL)
|
authSrv = rest.NewClient(oAuthClient).SetRoot(accountsURL)
|
||||||
apiSrv = rest.NewClient(oAuthClient).SetRoot(rootURL)
|
apiSrv = rest.NewClient(oAuthClient).SetRoot(rootURL)
|
||||||
@ -293,13 +293,19 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err
|
|||||||
}
|
}
|
||||||
authRetry := false
|
authRetry := false
|
||||||
|
|
||||||
|
// Bail out early if we are missing OAuth Scopes.
|
||||||
|
if resp != nil && resp.StatusCode == 401 && strings.Contains(resp.Status, "INVALID_OAUTHSCOPE") {
|
||||||
|
fs.Errorf(nil, "zoho: missing OAuth Scope. Run rclone config reconnect to fix this issue.")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Contains(resp.Header["Www-Authenticate"][0], "expired_token") {
|
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Contains(resp.Header["Www-Authenticate"][0], "expired_token") {
|
||||||
authRetry = true
|
authRetry = true
|
||||||
fs.Debugf(nil, "Should retry: %v", err)
|
fs.Debugf(nil, "Should retry: %v", err)
|
||||||
}
|
}
|
||||||
if resp != nil && resp.StatusCode == 429 {
|
if resp != nil && resp.StatusCode == 429 {
|
||||||
fs.Errorf(nil, "zoho: rate limit error received, sleeping for 60s: %v", err)
|
fs.Errorf(nil, "zoho: rate limit error received, sleeping for 60s: %v", err)
|
||||||
time.Sleep(60 * time.Second)
|
time.Sleep(180 * time.Second)
|
||||||
}
|
}
|
||||||
return authRetry || fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(resp, retryErrorCodes), err
|
return authRetry || fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(resp, retryErrorCodes), err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user