@@ -204,6 +204,10 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
204204 }
205205 }
206206 params .Add ("response" , "json" )
207+ params .Add ("signatureversion" , "3" )
208+ expirationTime := time .Now ().UTC ().Add (15 * time .Minute )
209+ expirationStr := expirationTime .Format ("2006-01-02T15:04:05Z" )
210+ params .Add ("expires" , expirationStr )
207211
208212 var encodedParams string
209213 var err error
@@ -220,8 +224,13 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
220224 mac := hmac .New (sha1 .New , []byte (secretKey ))
221225 mac .Write ([]byte (strings .ToLower (encodedParams )))
222226 signature := base64 .StdEncoding .EncodeToString (mac .Sum (nil ))
223- encodedParams = encodedParams + fmt .Sprintf ("&signature=%s" , url .QueryEscape (signature ))
224- params = nil
227+ if r .Config .Core .PostRequest {
228+ params .Add ("signature" , signature )
229+ } else {
230+ encodedParams = encodedParams + fmt .Sprintf ("&signature=%s" , url .QueryEscape (signature ))
231+ params = nil
232+ }
233+
225234 } else if len (r .Config .ActiveProfile .Username ) > 0 && len (r .Config .ActiveProfile .Password ) > 0 {
226235 sessionKey , err := Login (r )
227236 if err != nil {
@@ -287,7 +296,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
287296// we can implement further conditions to do POST or GET (or other http commands) here
288297func executeRequest (r * Request , requestURL string , params url.Values ) (* http.Response , error ) {
289298 config .SetupContext (r .Config )
290- if params .Has ("password" ) || params .Has ("userdata" ) {
299+ if params .Has ("password" ) || params .Has ("userdata" ) || r . Config . Core . PostRequest {
291300 requestURL = fmt .Sprintf ("%s" , r .Config .ActiveProfile .URL )
292301 return r .Client ().PostForm (requestURL , params )
293302 } else {
0 commit comments