【发布时间】:2021-03-20 15:56:07
【问题描述】:
我有一个从贝宝获取令牌的 API。
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"
我正在使用 axios 拨打电话,类似这样,但我在身份验证时遇到错误。
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);
});
可能是我错过了“grant_type”之类的内容...如何在此调用中传递这些参数。请你纠正一下?非常感谢你
【问题讨论】:
标签: javascript express axios paypal-sandbox paypal-rest-sdk