我是Node.js和Magento的新手。我必须阅读客户从Magento使用REST API。我得到下面的错误。请检查我的代码并指导我。
我遵循Magento API配置Magento REST web服务。
我正在使用StrongLoop框架。
Installed> npm oauth
var OAuth = require('oauth').OAuth;
var apiUrl = "http://domainname/api/rest/customers";
var oa = new OAuth(temporaryCredentialsRequestUrl, accessTokenRequestUrl, consumerKey, consumerSecret, 1.0, "http://localhost:3000/explorer", "HMAC-SHA1");
oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results){
if(error) {
console.log('error');
console.log(error);
}
else {
// store the tokens in the session
oa.get(apiUrl, oauth_token, oauth_token_secret,
function (error, data, response) {
var feed = JSON.parse(data);
console.log(data);
});
}
});
结果:{"信息":{"错误":{"代码":401年,"消息":"oauth_problem = token_rejected"}]}}
通过REST Api获取客户的详细信息是必须的。您必须配置此处定义的身份验证过程,请通读本文,您将得到答案。
我相信你没有外部用户权限。遵循这里
不确定这个问题仍然有效,但对我自己来说,我已经解决了这个问题,通过清理cookie登录后作为admin用户