When using the hmac handlebars helper to generate an authentication header or URI parameter, the Celigo platform provides and populates a set of hmacOptions
fields you can use to create the signature. hmacOptions
is a JSON object that contains fields that are commonly used to create authentication signatures (such as the request body and the URI). The following table lists all available fields:
Note
For demonstration purposes, the examples provided use the following full URL:
https://www.celigo-test.com/this/is/a/test?username=Integrator&domain=IO
Field name |
Description |
|
Path to parameters sent in the request header. |
|
The HTTP request body, in string format. |
|
Path to parameters sent in request body. |
|
The HTTP request method (verb). For example, PUT, POST, GET, etc. |
|
The contents of the http.encrypted field from your HTTP connection. If you store the key in your HTTP connection as hmacKey, it is available for use as hmacOptions.http.encrypted.hmacKey. |
|
The base URI used in the request. In this example, the value is:
|
|
The relative URI used in the request. In this example, the value is:
|
|
Reorders the query parameters in alphabetical order (except for 'sign' and 'access_token'. ('sign' and 'access_token' won't be present in this CautionCeligo does not check for typos or validate query parameters when using this option. |
|
The URL parameters used in the request. In this example, the value is:
|
|
Path to parameters sent in request URL. |
|
The full URI used in the request. In this example, the value is:
|
* Not available with authentication URL parameters.
To create an HMAC-SHA256 digest from the full URI in base64 format:
{{{hmac "sha256" hmacOptions.http.encrypted.hmacKey "base64" hmacOptions.URI}}}
To create an HMAC-SHA256 digest from the request body in hexadecimal format:
{{{hmac "sha256" hmacOptions.http.encrypted.hmacKey "hex" hmacOptions.body}}}
Example using hmacOptions.urlParametersMap.timestamp to create a signature included in the API request
Alibaba requires the following public parameters and service parameters:
Base URL: http://gw.api.taobao.com/router/rest
Public parameters:
method = “aliexpress.solution.order.fulfill” app_key = “12345678” session = “test” timestamp = “2016-01-01 12:00:00” format = “json” v = “2.0” sign_method = “md5”
Service parameters:
service_name = “SPAIN_LOCAL_CORREOS” out_ref = “1000006270175804” send_type=“all” logisitics_no=“ES2019COM0000123456”
The handlebars template to build the request is as follows:
http://gw.api.taobao.com/router/rest?method=aliexpress.solution.order.fulfill&app_key=12345678&session=test×tamp={{dateFormat "MM-DD-YYYY hh:mm:ss" timestamp}}&format=json&v=2.0&sign_method=md5&logistics_no=ES2019COM0000123456&out_ref=1000006270175804&send_type=all&service_name=SPAIN_LOCAL_CORREOS&sign={{{hmac 'md5' 'connection.http.encrypted.secret_key' 'hex' (join ‘’ ‘app_key’ ‘12345678’ ‘format’ ‘json’ ‘logisitics_no’ ‘ES2019COM0000123456’ ‘method’ ‘aliexpress.solution.order.fulfill’ ‘out_ref’ ‘1000006270175804’ ‘send_type’ ‘all’ ‘service_name’ ‘SPAIN_LOCAL_CORREOS’ ‘session’ ‘test’ ‘sign_method’ ‘md5’ ‘timestamp’ hmacOptions.urlParametersMap.timestamp ‘v’ ‘2.0’)}}}
The above handlebars template generates the following request which includes the required signature:
http://gw.api.taobao.com/router/rest?method=aliexpress.solution.order.fulfill&app_key=12345678&session=test×tamp=09-28-2023%2004%3A48%3A24&format=json&v=2.0&sign_method=md5&logistics_no=ES2019COM0000123456&out_ref=1000006270175804&send_type=all&service_name=SPAIN_LOCAL_CORREOS&sign=a70e11b72e9c728d2fc560993410dfe2
Comments
Please sign in to leave a comment.