When I send post request to https://api.molt.in/v1/customers/authenticate
I get strange return:
{"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.
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
That should have support for using a moltin.Customer.login()
method natively...