Search the Community
Showing results for tags 'paypal'.
-
Hi all, I'm not smart enough to clearly understand how to "translate this code into AutoIt call, so I used what I did in the past but it doesn't work properly. Basically I need to receive the Auth Token in order to place further calls. API docs on Paypal site says: curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token" \ -u "<CLIENT_ID>:<CLIENT_SECRET>" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials" or api-m.paypal.com if using live server. And this is my code (i just canceled the keys received from PP) #include <Array.au3> #include <string.au3> #include <MsgBoxConstants.au3> #Region Paypal Const Global $sURL = "https://api-m.paypal.com" ; /v1/oauth2/token - https://api-m.sandbox.paypal.com #EndRegion Paypal Const #Region keys Global $ClientID = "****" Global $SecretID = "****" #EndRegion keys _Test() Func _Test() Local $sResult = PayPalGet("/v1/oauth2/token") ConsoleWrite("$sResult: " & $sResult & @CRLF) EndFunc ;==>_Test Func PayPalGet($sMethod) Local $sJsonReq = '-u "' & $ClientID & ':' & $SecretID & '"' & _ '\ -H "Content-Type: application/x-www-form-urlencoded" \' & _ '-d "grant_type=client_credentials"' Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $sURL & $sMethod, False) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send(Binary($sJsonReq)) Local $sReceived = $oHTTP.ResponseText Return $sReceived Return $sReceived EndFunc ;==>PayPalGet When I run it I get: $sResult: {"error":"invalid_client","error_description":"Client Authentication failed"} Can you please help me to sort it out? Thanks in advance Marco