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

hubic: make error message more informative if authentication fails

Nick Craig-Woodd68b091170d4
diff --git a/backend/hubic/hubic.go b/backend/hubic/hubic.go
index 955ab7d3d..feab504a4 100644
--- a/backend/hubic/hubic.go
+++ b/backend/hubic/hubic.go
@@ -9,8 +9,10 @@ package hubic
import (
"encoding/json"
"fmt"
+ "io/ioutil"
"log"
"net/http"
+ "strings"
"time"
"github.com/ncw/rclone/backend/swift"
@@ -124,7 +126,9 @@ func (f *Fs) getCredentials() (err error) {
}
defer fs.CheckClose(resp.Body, &err)
if resp.StatusCode < 200 || resp.StatusCode > 299 {
- return errors.Errorf("failed to get credentials: %s", resp.Status)
+ body, _ := ioutil.ReadAll(resp.Body)
+ bodyStr := strings.TrimSpace(strings.Replace(string(body), "\n", " ", -1))
+ return errors.Errorf("failed to get credentials: %s: %s", resp.Status, bodyStr)
}
decoder := json.NewDecoder(resp.Body)
var result credentials