使用 NodeJS 的 OAuth 单元测试 MobileFirst Platform Java 适配器
Unit testing MobileFirst Platform Java Adapters with OAuth using NodeJS
我正在编写一个 NodeJS 应用程序来测试我编写的 IBM MobileFirst Platform 适配器。我想遵循的方法如下:
- 从 http://localhost:10080/AppName/authorization/v1/testtoken
获取测试令牌
- 使用此 Bearer 令牌向我的受保护适配器发出经过身份验证的请求。
方法的问题是,当我尝试向 testtoken 端点发出请求时,我收到 HTTP 405 状态错误。但是,同样适用于 PostMan。
有没有办法在 NodeJS 应用程序中实现此功能?我正在使用 Request 向 MobileFirst Server 发送请求。
我正在使用 SailsJs 编写我的 NodeJS 应用程序。
测试令牌操作需要 POST 请求。
request.post('http://localhost:10080/app/authorization/v1/testtoken', function(error, response, body) {
console.log(response.statusCode);
if(!error && response.statusCode == 200) {
console.log(body);
return res.ok(body);
} else {
return res.notFound(error);
}
});
在我的例子中,我使用的是请求,所以上面的代码有效。
我正在编写一个 NodeJS 应用程序来测试我编写的 IBM MobileFirst Platform 适配器。我想遵循的方法如下:
- 从 http://localhost:10080/AppName/authorization/v1/testtoken 获取测试令牌
- 使用此 Bearer 令牌向我的受保护适配器发出经过身份验证的请求。
方法的问题是,当我尝试向 testtoken 端点发出请求时,我收到 HTTP 405 状态错误。但是,同样适用于 PostMan。
有没有办法在 NodeJS 应用程序中实现此功能?我正在使用 Request 向 MobileFirst Server 发送请求。
我正在使用 SailsJs 编写我的 NodeJS 应用程序。
测试令牌操作需要 POST 请求。
request.post('http://localhost:10080/app/authorization/v1/testtoken', function(error, response, body) {
console.log(response.statusCode);
if(!error && response.statusCode == 200) {
console.log(body);
return res.ok(body);
} else {
return res.notFound(error);
}
});
在我的例子中,我使用的是请求,所以上面的代码有效。