为了确认付款,我需要access_token
。
我正在尝试使用httpRequest
来获取它:
Parse.Cloud.define("CheckPayment", function(request, response) {
var basicAuthString = "Basic AXo3jRDk:EEjf1hDMO5t0sKRXqHC62d";
Parse.Cloud.httpRequest({
method:"POST",
url: "https://api.sandbox.paypal.com/v1/oauth2/token",
headers: {
"Authorization":basicAuthString,
"Accept-Language": "en_US",
"Accept": "application/json"
},
body:{
grant_type:"client_credentials"
},
success: function(httpResponse) {
console.log(httpResponse.text);
response.success(httpResponse.text);
},
error: function(httpResponse) {
console.error("Request failed with response code " + httpResponse.status);
response.error(httpResponse.text);
}
});
});
要做以下卷曲:
curl -v 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"
我收到错误:
{"error":"invalid_client","error_description":"Invalid client credentials"}
你能帮帮我吗?我究竟做错了什么?
感谢