I have developed an API to retrieve a token from PayPal.
curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "CLIENT_ID:SECRET" \
-d "grant_type=client_credentials"
Currently, I am utilizing axios for making the call, but unfortunately facing authentication errors.
axios.post("https://api.sandbox.paypal.com/v1/oauth2/token", {}, {
auth: {
username: "xxxx, // clientId
password: "xxxx" // client Secret
}
}).then(function(response) {
result = response;
console.log('Authenticated' + response);
}).catch(function(error) {
console.log('Error on Authentication' + error);
});
It seems like I may have missed including the "grant_type" parameter in this call. How can I correctly pass these parameters in the request? Your assistance is greatly appreciated. Thank you!