omegahat / RCurl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using api key for authorization

simran-k opened this issue · comments

curl -u <USER API KEY>: "https://app.getblueshift.com/api/v1/campaigns.json?end_time=2016-03-31T18:29:59.999Z&start_time=2016-03-30T18:30:00.000Z&status=launched"

how do I do it in R?

I tried using:

blueShiftData <- curl_download(get(endPoint), paste0("/abc/rstudio/", endPoint), FALSE, "w", h)

and

h <- new_handle()

handle_setform(h, u = "API_ACCESS_KEY")

but it always gives me 404 unauthorized

You can do it with RCurl, but you are asking about functions that are in the curl package.

The curl option you want for use in RCurl is userpwd. That corresponds to -u on the command line.

Alright. I think I am a little lost at it. How do I do it with RCurl? I have been seeing username and password use for authentication but API key authentication isn't working for me. @duncantl

And that would also need me to have a username right? Or I can just omit it?

If the command line call you gave above (curl -u ....) works, then
getURLContent("https://app.getblueshift.com/api/v1/campaigns.json?end_time=2016-03-31T18:29:59.999Z&start_time=2016-03-30T18:30:00.000Z&status=launched", userpwd = "<USER_API_KEY>:")
should work.

If the curl -u command doesn't work, then you need to figure that out first and this is not a question about RCurl or the curl package.