I am trying to use Acumatica REST API (2020 R1) in a website using the below code.
async function loginAcumatica(){
try{
const { apiUrl, clientId, clientSecret, username, password } = await getCredentials();
const url = `${apiUrl}/identity/connect/token`;
const result = await axios.post(url, {
headers: {
'content-type': 'application/x-www-form-urlencoded'
},
body: `grant_type=password&client_id=${clientId}&client_secret=${clientSecret}&username=${username}&password=${password}&scope=api`
});
console.log(result);
return result;
}catch(err){
console.log(err);
}
}
Client ID and Client Secret values are from Acumatica's Connected Application. I have used the Resource Owner Password Credentials Auth type while creating a new record in the Connected Application. Username and Password are user login credentials.
However, I am not able to connect to API and always keep getting errors. Is there something that I am missing or it's not feasible?
Thanks.