npm-request

How to retrieve PayPal REST Api access-token using node

回眸只為那壹抹淺笑 提交于 2019-12-03 08:48:55
How to get the PayPal access-token needed to leverage the REST Api by using node? Once you have a PayPal client Id and a Client Secret you can use the following: 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); })