【问题标题】:Adobe Analytics Segments API auth issue with node.js clientnode.js 客户端的 Adob​​e Analytics Segments API 身份验证问题
【发布时间】:2017-12-30 06:11:42
【问题描述】:

我在尝试通过 node.js 客户端使用 Segments API 时遇到授权问题。 停止绕圈子,在它管理 POST 请求和通过 x-wsse 标头授权的部分下方:

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 Explorer 生成的 x-wsse,通过 Date() JS 类动态指定 Created 时间戳。 节点客户端向我报告此错误:
{"error":"Bad Request","error_description":"Unable to validate authentication.","error_uri":null}

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

非常感谢。

【问题讨论】:

  • 嗨,里卡多。您是否遇到过“创建的时间戳无效”错误?我正在尝试使用 Adob​​e Analytics API,并且使用的参数与 Adob​​e API 资源管理器输出的参数完全相同,但我仍然遇到该错误。
  • @knoll 请务必以 UTC 时间提交您的请求

标签: javascript node.js analytics adobe-analytics segments


【解决方案1】:

是的,PasswordDigestCreated 值也是动态生成的,因为它们基于您生成的值。我不太了解 node.js,无法向您展示 node.js 示例,但这是我所做的一个 php 示例,其中包含一些 cmets:

$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 看起来 Adob​​e 确实有一个 node sdk 可能有助于参考(或者只是使用..不确定您的最终情况是什么!)
猜你喜欢
  • 1970-01-01
  • 2016-01-22
  • 2018-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-23
  • 2012-12-06
相关资源
最近更新 更多