How to pass user and password in new_handle in curl R
You should set httpauth
and userpwd
options too:
h <- curl::new_handle()curl::handle_setopt( handle = h, httpauth = 1, userpwd = "user:passwd")resp <- curl::curl_fetch_memory("https://httpbin.org/basic-auth/user/passwd", handle = h)jsonlite::fromJSON(rawToChar(resp$content))#> $authenticated#> [1] TRUE#> #> $user#> [1] "user"