public class KayakoAPI {
public static string getSignature(string secretKey) {
string signature;
if (secretKey!=null && secretKey.length()>0) {
Blob salt = crypto.generateAesKey(128); //can use other ways for random string generation
// keyed hash
Blob hmacsha256 = crypto.generateMac('HmacSHA256', salt, Blob.valueOf(secretKey));
// Base64 and URL encoding
signature = EncodingUtil.urlEncode(EncodingUtil.base64Encode(hmacsha256), 'UTF-8');
}
return signature;
}
}
There must be a very good reason why we complicated our lives with all these technologies ... arguably that is freedom for something. Freedom might be a right but it is never free; so let me demonstrate how I earned it.
Monday, February 29, 2016
Apex code example for Kayako signature
Was looking at Kayako's API documentation - don't ask me why - and noticed there's no Apex example for their API request signature scheme (why would they?), so this might be useful for people who's in the same situation as I'm.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment