...
Code Block | ||||
---|---|---|---|---|
| ||||
Signature: { "AppKey": 12345, "IssuedAt": "yyyyMMddHHmmss", "Token": "hashed string" } |
AppKey
is is the unique numeric identifier of the application accessing the API. IssuedAt
is is the UTC timestamp at which the request was initiated. Token
is is a hashed string built with the following data:
...
The concatenated values in Token
are are a base64 encoded HMAC-SHA256 hash, using AppSecret
as as the key. Please note that RequestUrl
is is the complete URL.
If authentication fails, a HTTP status code 401 is returned along with information about the error: see Standard status codes - Bad signature
...
In order to create a new account, the app must initiate a POST request to:
https://api.dialogportalrubiq.comnet/v1/userentity
Let us assume the following details:
AppKey | 32767 |
---|---|
AppSecret | RCL1EDAYOVHANLL3A51G |
Request time | 8th of April 2014 at 04:59:51 UTC |
The application’s AppKey
is is 32767
, and it initiates the request on the 8th of April 2014 at 04:59:51 UTC, so the raw token is:
32767POSThttps://api.dialogportalrubiq.comnet/v1/user20140408045941entity20140408045941
When encrypted using AppSecret
RCL1EDAYOVHANLL3A51G
, the encrypted token is:
S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQeTqyykFcR5kN2kvb9RZiRXwV87xrowNREeNf6GGsIEA=
The complete signature will then look like this:
Code Block |
---|
Signature: { "AppKey": 32767, "IssuedAt": "20140408045941", "Token": "S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=" }"eTqyykFcR5kN2kvb9RZiRXwV87xrowNREeNf6GGsIEA=" } |
Making requests with Postman
Use the following "Pre-request Script" in Postman to generate the signature and add it as a request header:
Code Block | ||||
---|---|---|---|---|
| ||||
const AppKey = 32767;
const AppSecret = 'RCL1EDAYOVHANLL3A51G';
const IssuedAt = new Date().toISOString().replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+):?.*/, '$1$2$3$4$5$6');
const message = `${AppKey}${pm.request.method}${pm.request.url}${IssuedAt}`;
const Token = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(message, AppSecret));
const signature = { AppKey, IssuedAt, Token };
pm.request.headers.add({
key: "Signature",
value: JSON.stringify(signature)
}) |
Code Samples
The following code samples will return the encrypted token, using AppSecret as the encryption key
...