使用Appscript的API PayPal授权



以下操作失败,并出现错误:{quot;错误":quot;无效客户端"错误描述"客户端身份验证失败。目前还不清楚语法的哪个方面需要更改,因为我已经为另一个API使用了相同的格式,而且它已经起作用了。我能看到的唯一区别是PayPal的链接将OAuth2作为访问令牌类型,但他们确实定义了Basic可以与他们建议的开发平台Postman一起使用。

https://developer.paypal.com/api/rest/authentication/

function GetPayPalToken(){
response = UrlFetchApp.fetch('https://api-m.sandbox.paypal.com/v1/oauth2/token', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + Utilities.base64Encode(PayPalClientID+':'+PayPalKey)
},
grant_type: 'client_credentials',
muteHttpExceptions: true
});
console.log(response.getContentText());

}

如参考文档中所述,主体必须是grant_type=client_credentials

最新更新