Paypal rest api and Apps Script -


i'm trying use rest api of paypal. how can translate curl request token using urlfetchapp of apps script?

request sample

curl https://api.sandbox.paypal.com/v1/oauth2/token \  -h "accept: application/json" \  -h "accept-language: en_us" \  -u "eoj2s-z6oon_le_ks1d75wsz6y0sfdvsy9183ivxfyzp:eclusmeuk8e9ihi7zdvlf5cz6y0sfdvsy9183ivxfyzp" \  -d "grant_type=client_credentials" 

thank in advance

function trypaypal() {      var tokenendpoint = "https://api.sandbox.paypal.com/v1/oauth2/token";      var head = {       'authorization':"basic "+ utilities.base64encode("eoj2s-z6oon_le_ks1d75wsz6y0sfdvsy9183ivxfyzp:eclusmeuk8e9ihi7zdvlf5cz6y0sfdvsy9183ivxfyzp"),       'accept': 'application/json',       'content-type': 'application/x-www-form-urlencoded'     }      var postpayload = {         "grant_type" : "client_credentials"     }      var params = {         headers:  head,         contenttype: 'application/x-www-form-urlencoded',         method : "post",         payload : postpayload     }      var request = urlfetchapp.getrequest(tokenendpoint, params);      var response = urlfetchapp.fetch(tokenendpoint, params);       var result = response.getcontenttext();     logger.log(result);     var resultobject = json.parse(result);  } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -