我正在尝试将Paypal集成到我的应用中,但出现400错误[unsupported_grant_type]授予类型为NULL
axios
.post(
'https://api.sandbox.paypal.com/v1/oauth2/token',
{ grant_type: 'client_credentials' },
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
auth: {
username:
'clientId',
password:
'secret'
}
}
)
.then(response => {
console.log('response', response.data);
})
.catch(err => {
// console.log('error', { ...err });
console.log('error', err);
});
我做错了什么?
注意:它在邮递员中工作正常
答案 0 :(得分:2)
我找到了解决方法。
束紧身体。
添加
const qs = require('querystring');
qs.stringify({ grant_type: 'client_credentials' })