[英]Customer authenticate
When I send post request to https://api.molt.in/v1/customers/authenticate
I get strange return: 当我将发帖请求发送到
https://api.molt.in/v1/customers/authenticate
我得到奇怪的回报:
{"status":false,"error":"HTTP method used is not supported for this endpoint"}
I only get this error if I add custom header: 如果添加自定义标头,只会出现此错误:
'Authorization':'Bearer ' + token_data.access_token
You can see my full code here: 您可以在此处查看我的完整代码:
var formData = {grant_type:'implicit', client_id: clientId}
request.post({url:'https://api.molt.in/oauth/access_token',form:formData}, function (err, httpResponse, body){
if(err){
console.log(err);
}
token_data = JSON.parse(body);
});
moltin.Authenticate(function(){
var options = {url:'https://api.molt.in/v1/customers/authenticate',
form:{email:"xxxx@xxx.com", password:'xxxx'},
headers: {
'Authorization':'Bearer ' + token_data.access_token
}
};
function callBack(err, httpResponse, body){
if(err){
console.log(err);
}
console.log("\naccess_token: "+token_data.access_token+"\nbody: "+body);
res.send(body);
}
request.post(options,callBack);
});
If you call https://api.molt.in/v1/customers/token
instead of https://api.molt.in/v1/customers/authenticate
then you should get back the customer token that you can then use for subsequent requests. 如果您致电
https://api.molt.in/v1/customers/token
而不是https://api.molt.in/v1/customers/authenticate
那么您应该取回客户令牌,然后将其用于后续操作要求。
If you're using JS and can add in the moltin SDK manually, build a copy from this branch: https://github.com/moltin/js-sdk/tree/feature/customer-logins 如果您使用的是JS并且可以手动添加moltin SDK,请从以下分支构建副本: https : //github.com/moltin/js-sdk/tree/feature/customer-logins
That should have support for using a moltin.Customer.login()
method natively... 那应该支持本地使用
moltin.Customer.login()
方法...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.