如何使用节点检索 PayPal REST Api 访问令牌

2023-12-22

如何使用节点获取利用 REST Api 所需的 PayPal 访问令牌?


一旦您拥有 PayPal 客户端 ID 和客户端密钥,您就可以使用以下内容:

var request = require('request');

request.post({
    uri: "https://api.sandbox.paypal.com/v1/oauth2/token",
    headers: {
        "Accept": "application/json",
        "Accept-Language": "en_US",
        "content-type": "application/x-www-form-urlencoded"
    },
    auth: {
    'user': '---your cliend ID---',
    'pass': '---your client secret---',
    // 'sendImmediately': false
  },
  form: {
    "grant_type": "client_credentials"
  }
}, function(error, response, body) {
    console.log(body);
});

如果成功,响应将如下所示:

{
    "scope":"https://api.paypal.com/v1/payments/.* ---and more URL callable with the access-token---",
    "access_token":"---your access-token---",
    "token_type":"Bearer",
    "app_id":"APP-1234567890",
    "expires_in":28800
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用节点检索 PayPal REST Api 访问令牌 的相关文章

随机推荐