Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with auth for https://mixpanel.com/ #6

Open
clinderDemiurge opened this issue Oct 29, 2018 · 1 comment
Open

Issues with auth for https://mixpanel.com/ #6

clinderDemiurge opened this issue Oct 29, 2018 · 1 comment

Comments

@clinderDemiurge
Copy link

Hello,

I can't seem to authenticate with any https://mixpanel.com/ endpoints. This includes segmentation and funnels. Based on the simple funnel example I tried the following:

This doesn't work - "object 'res' not found"

mixpanelGetData(account, method="funnels/list/", args=list(), data=TRUE)

This doesn't work either - "Unknown SSL protocol error in connection to mixpanel.com:443"

headers = c(Authorization = paste("Basic ", base64enc::base64encode(charToRaw(paste(account$apiSecret,
":", account$apiSecret, sep = ""))), sep = ""))
url <- "https://mixpanel.com/api/2.0/funnels/list/?"
RCurl::getURL(url, httpheader = headers)

Also doesn't work - "AuthenticationRequiredAuthentication required."

url <- "https://data.mixpanel.com/api/2.0/funnels/list/?"
RCurl::getURL(url, httpheader = headers)

However the following does work:

url <- "https://data.mixpanel.com/api/2.0/export/?event=%5B%22Purchase3%22%5D&from_date=2018-10-01&to_date=2018-10-02&"
RCurl::getURL(url, httpheader = headers)

myArgs <- list()
myArgs$event <- "["Purchase3"]"
myArgs$from_date <- "2018-10-01"
myArgs$to_date <- "2018-10-02"
mixpanelGetData(account, method="export/", args=myArgs, data=TRUE)

Any idea what is going on? Thanks in advance.

@clinderDemiurge
Copy link
Author

Hello again,

I'm not sure this is the best fix but I've found a work around by making a local change in mixpanelGetData replacing "RCurl" with "crul".

  # Not using RCurl because auth doesn't work for non-export endpoints
  # res <- RCurl::getURL(url, httpheader=headers, .encoding=encoding) # See fork https://github.com/jzking/RMixpanel.
  
  # Using crul instead of RCurl
  resHttp <- crul::HttpClient$new(
    url = url,
    auth = crul::auth(user = account$apiSecret, pwd = account$apiSecret)
  )
  x <- resHttp$get()
  res <- x$parse(encoding)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant