如何通过使用节点获得利用REST Api所需的PayPal访问令牌? 获得PayPal客户端ID和客户端密钥后,您可以使用以下内容: var request = require('request');request.post({ uri: "https://api.sandbox.paypal.com/v1/o
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 }