I am trying to read data from my company intranet sharepoint.
require(httr)
url <- "http://<domain>/<path>/_vti_bin/ListData.svc/<something>"
r <- GET(url)
The problem is, access to Sharepoint uses Windows authentication. The above, expectedly, gave me 401 Unauthorized error.
How can I incorporate my windows authentication into the request in R, without typing my credential in clear text in the GET
parameter? (using authenticate()
with my credentials do work).
authenticate()
is the right function to use, but you need to change the input as shown below:
require(httr)
url <- "http://<domain>/<path>/_vti_bin/ListData.svc/<something>"
r <- GET(url, authenticate("username","password",type="any"))
I'm not sure which specific type works, but I was able to establish a session using any. I found the solution in the httr package documentation.
https://cran.r-project.org/web/packages/httr/httr.pdf
Get your site-id as outlined here. Get your list-id as outlined here. If you need to expand any list items, check this out.
And to make sure you don't pull your hair out and go bald like me, make sure that your item-level permissions for read access in the SharePoint site are set to "Read all items" (here's a reference).
library(AzureGraph)
gr <- create_graph_login()
me <- gr$get_user("me")
url <- "https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items"
r <- call_graph_url(me$token, url, http_verb = c("GET"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With