@@ -308,7 +308,6 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
308308
309309 var encodedParams string
310310 var err error
311- usingAPIKeySecretKey := false
312311
313312 if len (r .Config .ActiveProfile .APIKey ) > 0 && len (r .Config .ActiveProfile .SecretKey ) > 0 {
314313 apiKey := r .Config .ActiveProfile .APIKey
@@ -328,7 +327,6 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
328327 encodedParams = encodedParams + fmt .Sprintf ("&signature=%s" , url .QueryEscape (signature ))
329328 params = nil
330329 }
331- usingAPIKeySecretKey = true
332330 } else if len (r .Config .ActiveProfile .Username ) > 0 && len (r .Config .ActiveProfile .Password ) > 0 {
333331 sessionKey , err := Login (r )
334332 if err != nil {
@@ -351,7 +349,11 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
351349 }
352350 config .Debug ("NewAPIRequest response status code:" , response .StatusCode )
353351
354- if response .StatusCode == http .StatusUnauthorized && ! usingAPIKeySecretKey {
352+ if r .CredentialsSupplied {
353+ config .Debug ("Credentials supplied on command-line, not falling back to login" )
354+ }
355+
356+ if response .StatusCode == http .StatusUnauthorized && ! r .CredentialsSupplied {
355357 r .Client ().Jar , _ = cookiejar .New (nil )
356358 sessionKey , err := Login (r )
357359 if err != nil {
0 commit comments