0
votes

I want to use the Paypal REST API in my titanium app, I write code like this :

function paypal(){
var data = {grant_type: 'client_credentials'};
var xhr = Titanium.Network.createHTTPClient({
    onload: function() {
        alert(this.responseText);
    },
    onerror: function(e) {
        alert(e.error);
    },
    timeout : 5000
});
xhr.open('POST', 'https://clientID:secret@api.sandbox.paypal.com/v1/oauth2/token');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Accept-Language','en_us');
xhr.send(data);
}

But it keep response as error and said : Authentication Needed
Can anybody give me a help? Thanks a lot!

1

1 Answers

1
votes

There is already a titanium module for Paypal , so you can use it easily.