Access to sharepoint in R with Windows Authentication

I am trying to read data from my company's sharepoint.

require(httr)
url <- "http://<domain>/<path>/_vti_bin/ListData.svc/<something>"
r <- GET(url)

The problem is that Sharepoint access uses Windows authentication. The above is expected to give me 401 Unauthorized error.

How can I include Windows authentication in a request in R without entering my credentials in clear text in the parameter GET? (using authenticate()with my credentials really works).

+5
source share
4 answers

authenticate() is the correct 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"))

, , , . httr.

https://cran.r-project.org/web/packages/httr/httr.pdf

+1

, , pw , getPass, getPass (msg = "message, "), ( , ), .

: , , , , . , - RStudio, , , :

require(httr)
require(getPass)

user <- getPass(msg="Enter User ID: ")
pw <- getPass(msg="Enter password: ")

url <- "http://<domain>/<path>/_vti_bin/ListData.svc/<something>"
r <- GET(url, authenticate(user,pw,type="any"))
0

SharePoint , RCurl XML. , .

library(RCurl)
library(XML)
URL = "http://<domain>/<path>/_vti_bin/ListData.svc/<something>"
rawData = getURL(URL,userpwd=:"username:password")
xmlData = xmlParse(rawData)
items = getNodeSet(xmlData,"//m:properties")
df = xmlToDataFrame(items,stringsAsFactors=F)
0

SharePoint SharePoint Online: https://github.com/LukasK13/sharepointr

, .

0

All Articles