banboo-data / RCriteo

Loading Criteo Campaign Data into R
http://jburkhardt.github.io/RCriteo/
Other
6 stars 3 forks source link

doCriteoAuth returns NULL (empty) #4

Closed connelldan closed 9 years ago

connelldan commented 9 years ago

Not sure why I cant get this to work. I do have username and password

authToken <- doCriteoAuth(user = "*****", password = "*****", company = "company", app =    "appName", version = "3.6")

Im also using options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

This helps me avoid this error message: Error in function (type, msg, asError = TRUE) : SSL certificate problem: unable to get local issuer certificate

I was looking at the function and noticed the API url is v2010 but my acct manager shows documentation with v201305

Could that be part of the issue?

jburkhardt commented 9 years ago

As already mentioned, the package is working fine and is in productive usage on OSx and Ubuntu 12.04. v2010 is still fine. See the documentation here: http://kb.criteo.com/advertising/content/5/27/en/api.html If you want to use the Criteo API, Criteo has to set up and upgrade your account first. With just a usual account login you are not coming far. Criteo has to provide a user, password and app token for API access. With the user and password doCriteoAuth delivers an auth token. With the auth token in combination with the app token you can pull data.

connelldan commented 9 years ago

Yes - This is WITH the upgraded account and unique username and password. The account has been updated for both issues mentioned.

jburkhardt commented 9 years ago

Well, I cannot reproduce your problem obviously. Thus it would be helpful if you provide me more information about your operating system, R version, RCurl version. What do you get if you run the code of the doCriteoAuth function step by step? What does the object xmlParse(h$value()) return?

library(RCurl)
library(XML)

user = "********"
password = "********"
company = "company"
app = "appName"
version = "3.6"

headerFields =
    c(Accept = "text/xml",
      Accept = "multipart/*",
      'Content-Type' = "text/xml; charset=utf-8",
      SOAPAction = "https://advertising.criteo.com/API/v201010/clientLogin")

  body = paste('<?xml version="1.0" encoding="utf-8"?>
               <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
               <soap:Body>
               <clientLogin xmlns="https://advertising.criteo.com/API/v201010">
               <username>', user ,'</username>
               <password>', password,'</password>
               <source>',company,'-', app ,'-', version,'</source>
               </clientLogin>
               </soap:Body>
               </soap:Envelope>',sep="")

  h = RCurl::basicTextGatherer()
  RCurl::curlPerform(url = "https://advertising.criteo.com/API/v201010/AdvertiserService.asmx",
              httpheader = headerFields,
              postfields = body,
              writefunction = h$update
  )
xmlParse(h$value())
connelldan commented 9 years ago

Unfortunately it shows bad authentication. I re copied and pasted my API username and password with no success. Perhaps it's a different version? Thanks for your help.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>bad authentication</faultstring>
      <detail/>
    </soap:Fault>
  </soap:Body>
</soap:Envelope> 
jburkhardt commented 9 years ago

Ok - the communication between R and the Criteo API is not causing the problem. There has to be anything inappropriate with your api account login settings. Maybe your account manager could test your credentials.

connelldan commented 9 years ago

Thanks for your patience with me here. It was due to faulty credentials. My account rep fixed them and I am now able to obtain authToken()!