...
https://api.dialogportal.com/v1/user
If we Let us assume that the the following details:
AppKey | 32767 |
---|---|
AppSecret | RCL1EDAYOVHANLL3A51G |
Request time | 8th of April 2014 at 04:59:51 UTC |
The application’s AppKey is 3276832767, and that it initiates the request on the 8th of February 2013 April 2014 at 0704:1859:00 51 UTC, so the raw token is:
32768POSThttps 32767POSThttps://api.dialogportal.com/v1/user20130208071800user20140408045941
The following C# method will return the encrypted token, using the AppSecret as the encryption key:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public static string EncryptToken(string secret, string token) { byte[] bytesSecret = Encoding.UTF8.GetBytes(secret); using (var hmacsha256 = new HMACSHA256(bytesSecret)) { byte[] tokenBytes = Encoding.UTF8.GetBytes(token); return Convert.ToBase64String(hmacsha256.ComputeHash(tokenBytes)); } } |
When encrypted using AppSecret RCL1EDAYOVHANLL3A51G, the encrypted token is:
S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=
The complete signature will then look like this:
Code Block |
---|
Signature: { "AppKey": 3276832767, "IssuedAt": "2013020807180020140408045941", "Token": "wytqCR4v1jmZxo22CeC0Qlp9sGi/MJ47G/Yitjg2X8US/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=" } |