Updated on 2024-05-31 GMT+08:00

HTTP Body Signature

Definition

Each time KooGallery calls your interface, KooGallery generates a signature for the request based on certain rules and adds the signature to the URL as a URL parameter. After receiving the request, you need to recalculate the signature for the request body based on the same rules, compare the signature with the signature transferred by KooGallery. If they are the same, the verification succeeds. The following table lists the parameters transferred.

Parameter

Value

Description

signature

String

Encrypted signature, which is generated by signing a request based on certain rules.

timestamp

Long

UNIX timestamp, in seconds. The difference between the timestamp and the current time must not exceed 60 seconds.

nonce

String

Randomly generated by KooGallery each time an interface is called. You can cache it to defend against replay attacks.

Generation Rules

  1. Sort request parameters by name (from Z to A). For example, a parameter whose name starts with a is placed after a parameter whose name starts with b.
  2. Obtain the standard request character string.
canonicalRequest = accessKey + nonce + timestamp + Lowercase(HexEncode(HMAC_SHA256 (RequestPayload)))
  1. Obtain the signature value for the key.
signature = HexEncode(HMAC_SHA256(canonicalRequest))

Example

The following is an example of the request received by you:

curl -X POST -H 'Content-Type: application/json' 'https://www.isvwebsite.com/saasproduce?signature=af71c5a7ef45310b8dc05ab15f7da50189ffa81a95cc284379ebaa5eb61155c0&timestamp=1666677988730&nonce=RLLUammMSInlrNWb' --data '{"activity":"newInstance","buyerInfo":{"customerId":"688055390f3049f283fe9f1aa90f1858","customerName":"CBC_marketplace_mwx616072_01","userId":"1e86066c22754361933f607df834e4fe","userName":"CBC_marketplace_mwx616072_01","mobilePhone":"18652996659","email":"mapengfei8@huawei.com"},"orderInfo":[{"businessId":"8a2c4e6f-405a-4f8d-8e24-f41090522646","orderId":"CS2210101920BWXLK","trialFlag":"0","orderAmount":12.78,"chargingMode":"PERIOD","periodType":"month","periodNumber":5,"provisionType":1,"productInfo":[{"skuCode":"a63ee5c9-4f86-11ed-9f95-fa163e8cb3b2","productId":"OFFI788963615933718528","linearValue":20}],"createTime":"20221024194509","expireTime":"20221224194509","extendParams":[{"name":"emailDomainName","value":"test.xxxx.com"},{"name":"extendParamName","value":"extendParamValue"}]}],"testFlag":"1"}'