Javascript Adobe Analytics Segments API验证问题与node.js客户端

Javascript Adobe Analytics Segments API验证问题与node.js客户端,javascript,node.js,analytics,adobe-analytics,segments,Javascript,Node.js,Analytics,Adobe Analytics,Segments,我在试图通过node.js客户端使用Segments API时遇到授权问题。 停止拐弯抹角,在通过x-wsse头管理POST请求和授权的it部分下方: var now = new Date(); var options = { method: "POST", hostname: "api3.omniture.com", path: "/admin/1.4/rest/?method=Segments.Get", json: true, header

我在试图通过node.js客户端使用Segments API时遇到授权问题。 停止拐弯抹角,在通过x-wsse头管理POST请求和授权的it部分下方:

var now = new Date();
var options = {
     method: "POST",
     hostname: "api3.omniture.com",
     path: "/admin/1.4/rest/?method=Segments.Get",
     json: true,
     headers: {
            "Content-Type": "application/json",
            "Content-Length" : Buffer.byteLength(JSON.stringify(body)),
            "x-wsse": 'UsernameToken Username="[username]:[company]", PasswordDigest="xxxxxxxxxxxxxxxxxxxxxxxxxx==", Nonce="yyyyyyyyyyyyyyyyyyyyyyyyyy", Created="'+now+'"'
     }
};
如您所见,我正在尝试复制API资源管理器生成的x-wsse,通过Date()JS类动态指定创建的timestap。 节点客户端正在向我报告此错误:
{“错误”:“错误请求”,“错误描述”:“无法验证身份验证”,“错误uri”:null}

我假设x-wsse PasswordDigest和Nonce值在每次请求时也会不断变化,而在这里我将它们设置为静态。 如果这是问题的原因,那么如何在x-wsse头中动态插入这些参数


非常感谢。

是的,创建的
PasswordDigest
值也是动态生成的,因为它们基于您生成的值。我对node.js了解不够,无法向您展示一个node.js示例,但下面是一个php示例,说明我所做的工作,并附上一些注释:

$username='user:company';
$secret='12345'; // api shared secret key for the user
// The nonce should be a universally unique value. I use a timestamp based value and prefix with a namespace to help make it unique, because AA request digests have to be unique across everybody everywhere ever
$nonce = 'FOO_'.dechex(time());
// datetime stamp in ISO 8601 date format (e.g. '2004-02-12T15:19:21+00:00')
$nonce_ts = date('c');
// Adobe expects the PasswordDigest to be a concatenated string value of the nonce, datetimestamp, and api key. They expect it to be hashed (sha1) and then base64 encoded
$digest = base64_encode(sha1($nonce.$nonce_ts.$secret));
$server = "https://api.omniture.com";
$path = "/admin/1.4/rest/";
$rc=new SimpleRestClient();
$rc->setOption(CURLOPT_HTTPHEADER, array("X-WSSE: UsernameToken Username=\"$username\", PasswordDigest=\"$digest\", Nonce=\"$nonce\", Created=\"$nonce_ts\""));

是的,
PasswordDigest
创建的
值也是动态生成的,因为它们基于您生成的值。我对node.js了解不够,无法向您展示一个node.js示例,但下面是一个php示例,说明我所做的工作,并附上一些注释:

$username='user:company';
$secret='12345'; // api shared secret key for the user
// The nonce should be a universally unique value. I use a timestamp based value and prefix with a namespace to help make it unique, because AA request digests have to be unique across everybody everywhere ever
$nonce = 'FOO_'.dechex(time());
// datetime stamp in ISO 8601 date format (e.g. '2004-02-12T15:19:21+00:00')
$nonce_ts = date('c');
// Adobe expects the PasswordDigest to be a concatenated string value of the nonce, datetimestamp, and api key. They expect it to be hashed (sha1) and then base64 encoded
$digest = base64_encode(sha1($nonce.$nonce_ts.$secret));
$server = "https://api.omniture.com";
$path = "/admin/1.4/rest/";
$rc=new SimpleRestClient();
$rc->setOption(CURLOPT_HTTPHEADER, array("X-WSSE: UsernameToken Username=\"$username\", PasswordDigest=\"$digest\", Nonce=\"$nonce\", Created=\"$nonce_ts\""));

@RiccardoMalesani btw看起来Adobe确实有一个可能有助于参考(或只是使用..不确定您的最终情况是什么!)@RiccardoMalesani btw看起来Adobe确实有一个可能有助于参考(或只是使用..不确定您的最终情况是什么!)Hi Riccardo。您是否遇到过“创建的时间戳无效”错误?我正在使用Adobe Analytics API进行实验,使用的参数与Adobe API explorer输出的参数完全相同,但我仍然会遇到这个错误。@我一定会用UTCHi Riccardo提交您的请求。您是否遇到过“创建的时间戳无效”错误?我正在使用Adobe Analytics API进行试验,使用的参数与Adobe API explorer输出的参数完全相同,但我仍然会遇到这个错误。@我会确保在UTC中提交您的请求