根据文档,如果您使用他们的 SDK 之一,它将自动验证您的请求:
SDK 已经为您处理身份验证。您只需提供
带有为您生成的客户端 ID 和客户端密钥的 SDK
客户端创建时。如果您没有使用 SDK,请使用代码
右侧的示例生成您自己的 HTTP 标头以进行身份验证
你的申请。
但是,如果您想手动执行此操作,我相信您需要计算HMAC他们在您的问题的链接中描述的字符串的值,然后将其以 Base64 编码作为Hound-Client-Authentication
您的请求中的标头。他们提供了一个Node.js 的示例:
var uuid = require('node-uuid');
var crypto = require('crypto');
function generateAuthHeaders (clientId, clientKey, userId, requestId) {
if (!clientId || !clientKey) {
throw new Error('Must provide a Client ID and a Client Key');
}
// Generate a unique UserId and RequestId.
userId = userId || uuid.v1();
// keep track of this requestId, you will need it for the RequestInfo Object
requestId = requestId || uuid.v1();
var requestData = userId + ';' + requestId;
// keep track of this timestamp, you will need it for the RequestInfo Object
var timestamp = Math.floor(Date.now() / 1000),
unescapeBase64Url = function (key) {
return key.replace(/-/g, '+').replace(/_/g, '/');
},
escapeBase64Url = function (key) {
return key.replace(/\+/g, '-').replace(/\//g, '_');
},
signKey = function (clientKey, message) {
var key = new Buffer(unescapeBase64Url(clientKey), 'base64');
var hash = crypto.createHmac('sha256', key).update(message).digest('base64');
return escapeBase64Url(hash);
},
encodedData = signKey(clientKey, requestData + timestamp),
headers = {
'Hound-Request-Authentication': requestData,
'Hound-Client-Authentication': clientId + ';' + timestamp + ';' + encodedData
};
return headers;
};