node.js - Salesforce Commerce Cloud 控制器身份验证
问题描述
我在商业云中做了一个控制器,以便从外部订单管理服务更新订单。
然后 Commerce Cloud 内部的控制器将通过 POST 方法接收订单详细信息,并相应地将更新保存在订单中。
问题是我无法通过外部资源发送请求。对于任何请求,我都会收到结果:
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>401 - Authorization Required.</title>
<link rel="STYLESHEET" type="text/css" href="/waroot/style.css">
</head>
我正在发送请求以获取https://account.demandware.com/dwsso/oauth2/access_token中的令牌,并使用正确的令牌发送请求以及资源位置的令牌,遵循https://中给出的示例documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2Fcontent%2Fb2c_commerce%2Ftopics%2Fsearch_engine_optimization%2Fb2c_digital_url_syntax_without_seo.html
例如:https://localhost/on/demandware.store/Sites-SiteGenesis-Site/default/Hello-World
我尝试了两种不同的控制器:
server.post('Test', function (req, res, next) {
try {
Transaction.wrap(function () {
// Some logic
});
} catch(e) {
Logger.error('Exception "{0}"" .', e.message);
}
next();
});
还有一个更简单的方法:
exports.Test = function(){
response.getWriter().println('Hello World!');
};
exports.Test.public = true;
但无论我做什么,我总是收到 401 - Authorization Required 响应。
我应该更改身份验证过程、控制器或我的资源位置是否有问题以允许来自第三方系统的请求访问我的控制器?
解决方案
推荐阅读
- vue.js - vue js v-model 重新渲染列表并使输入速度极慢
- postgresql - 如何添加更多列以对分区求和?
- javascript - 我收到此代码的“ReferenceError:无效分配左侧”错误。我看不出有什么问题
- vue.js - 在Vuex模块中获取对象值而不是观察者类型
- c# - DDD 中的类别聚合根
- c# - 如何从 Delphi 调用 C# 程序并收集返回值?
- javascript - 有什么方法可以更改电子文件对话框的标题和保存类型?
- php - 为现有的 laravel 项目安装 jetstream 是否安全?
- asp.net - 收到此错误“逗号,')',或预期的有效表达式继续”
- c - 我是否需要为指针分配空间以及为内存区域分配空间,其地址将保存在指向指针和 realloc 的指针中