diff --git a/cmd/network.go b/cmd/network.go index 1c1f67c..abfc7ac 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -211,6 +211,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str var encodedParams string var err error + usingAPIKeySecretKey := false if len(r.Config.ActiveProfile.APIKey) > 0 && len(r.Config.ActiveProfile.SecretKey) > 0 { apiKey := r.Config.ActiveProfile.APIKey @@ -230,7 +231,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature)) params = nil } - + usingAPIKeySecretKey = true } else if len(r.Config.ActiveProfile.Username) > 0 && len(r.Config.ActiveProfile.Password) > 0 { sessionKey, err := Login(r) if err != nil { @@ -253,7 +254,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str } config.Debug("NewAPIRequest response status code:", response.StatusCode) - if response.StatusCode == http.StatusUnauthorized { + if response.StatusCode == http.StatusUnauthorized && !usingAPIKeySecretKey { r.Client().Jar, _ = cookiejar.New(nil) sessionKey, err := Login(r) if err != nil {