Using cURL behind password site

I'm having trouble downloading a csv file saved behind a site with a username and password. I think I am doing something wrong with the handle, but don't understand curl enough to fix it.


url <- "XXX Sex - Free Porn Videos at"

h <- new_handle()

handle_setopt(handle = h,
httpauth = 1,
userpwd = "user123:hunter2")

req <- curl_fetch_memory(url, handle = h)

When it executes, I'm getting a list of 6 elements and the status_code element is 401.

Thanks for any insights

you could try with {httr} but I think it is the same:

GET(url, authenticate(user, password))