1

So i am trying to integrate PayPal in my Flex Mobile app. I make my first call like this:

(keys are sandbox by paypal dev resources)

protected function getPaypal():void { 
  var client_id:String="EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp"; 
  var secret:String="EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp"; 

  var params:Object = new Object(); 
  params.grant_type="client_credentials"; 

  var encoder:Base64Encoder = new Base64Encoder(); 
  encoder.encode(client_id + ":" + secret); 

  //var s:String = JSON.stringify(params); 
  paypal.contentType = "application/x-www-form-urlencoded"; 
  paypal.headers["Authorization"] = "Basic " + encoder.toString(); 
  paypal.method = "POST"; 
  paypal.url = "https://api.sandbox.paypal.com/v1/oauth2/token"; 
  paypal.send(params); 
  } 

This fails and returns the following:

'Error #2096: The HTTP request header Basic RU9KMlMtWjZPb05fbGVfS1MxZDc1d3NaNnkwU0ZkVnNZOTE4M0l2eEZ5WnA6RUNsdXNNRVVrOGU5 
aWhJN1pkVkxGNWNaNnkwU0ZkVnNZOTE4M0l2eEZ5WnA= cannot be set via ActionScript.' faultDetail:'null' 

I can't figure out what seems to be the problem.

Any help?

leokan
  • 662
  • 5
  • 22

1 Answers1

2

Maybe this? https://stackoverflow.com/a/539173/3384609

Gist:

You can fix this by setting (in the above example) encoder.insertNewLines = false; The default setting is true.

Community
  • 1
  • 1
Clintm
  • 4,505
  • 3
  • 41
  • 54