TheProjecter / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

support sharepointOnline? #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
String username="xx@xx.onmicrosoft.com";
String password="xxx";
Sardine sardine = SardineFactory.begin(username, password);
String root = "https://xx.sharepoint.com/Documents/";
List<DavResource> resources = sardine.list(root);
for(DavResource dr : resources){
    System.out.println(dr);
}
result:
Unexpected response (403 FORBIDDEN)

Does sharepointOnline support sardine?

Original issue reported on code.google.com by chen...@ustcsoft.com on 22 Dec 2011 at 2:34

GoogleCodeExporter commented 9 years ago
Please enable logging with log4j and set the `org.apache.http.headers` logger 
to `debug`. This will print the request and response headers.

Original comment by dkocher@sudo.ch on 22 Dec 2011 at 11:05

GoogleCodeExporter commented 9 years ago
DEBUG - Get connection: HttpRoute[{}->http://testofebt.sharepoint.com], timeout 
= 0
DEBUG - [HttpRoute[{}->http://testofebt.sharepoint.com]] total kept alive: 0, 
total issued: 0, total allocated: 0 out of 20
DEBUG - No free connections 
[HttpRoute[{}->http://testofebt.sharepoint.com]][null]
DEBUG - Available capacity: 2 out of 2 
[HttpRoute[{}->http://testofebt.sharepoint.com]][null]
DEBUG - Creating new connection [HttpRoute[{}->http://testofebt.sharepoint.com]]
DEBUG - Connecting to testofebt.sharepoint.com:80
DEBUG - CookieSpec selected: best-match
DEBUG - Auth cache not set in the context
DEBUG - Attempt 1 to execute request
DEBUG - Sending request: PROPFIND /TeamSite/Documents/ HTTP/1.1
DEBUG - >> "PROPFIND /TeamSite/Documents/ HTTP/1.1[\r][\n]"
DEBUG - >> "Depth: 1[\r][\n]"
DEBUG - >> "Content-Type: text/xml; charset=utf-8[\r][\n]"
DEBUG - >> "Content-Length: 99[\r][\n]"
DEBUG - >> "Host: testofebt.sharepoint.com[\r][\n]"
DEBUG - >> "Connection: Keep-Alive[\r][\n]"
DEBUG - >> "User-Agent: Sardine/UNAVAILABLE[\r][\n]"
DEBUG - >> "[\r][\n]"
DEBUG - >> PROPFIND /TeamSite/Documents/ HTTP/1.1
DEBUG - >> Depth: 1
DEBUG - >> Content-Type: text/xml; charset=utf-8
DEBUG - >> Content-Length: 99
DEBUG - >> Host: testofebt.sharepoint.com
DEBUG - >> Connection: Keep-Alive
DEBUG - >> User-Agent: Sardine/UNAVAILABLE
DEBUG - >> "<?xml version="1.0" encoding="UTF-8" standalone="yes"?><propfind 
xmlns="DAV:"><allprop/></propfind>"
DEBUG - << "HTTP/1.1 403 FORBIDDEN[\r][\n]"
DEBUG - << "Content-Type: text/html; charset=utf-8[\r][\n]"
DEBUG - << "Server: Microsoft-IIS/7.5[\r][\n]"
DEBUG - << "SPRequestGuid: b602e351-0301-4095-878c-7df1b893ef42[\r][\n]"
DEBUG - << "X-SharePointHealthScore: 0[\r][\n]"
DEBUG - << "X-Forms_Based_Auth_Required: 
http://testofebt.sharepoint.com/_forms/default.aspx?ReturnUrl=/_layouts/Error.as
px[\r][\n]"
DEBUG - << "X-Forms_Based_Auth_Return_Url: 
http://testofebt.sharepoint.com/_layouts/Error.aspx[\r][\n]"
DEBUG - << "X-MSDAVEXT_Error: 917656; Access denied. Before opening files in 
this location, you must first browse to the web site and select the option to 
login automatically.[\r][\n]"
DEBUG - << "X-Powered-By: ASP.NET[\r][\n]"
DEBUG - << "MicrosoftSharePointTeamServices: 14.0.0.6106[\r][\n]"
DEBUG - << "P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI 
TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"[\r][\n]"
DEBUG - << "Date: Fri, 23 Dec 2011 03:05:50 GMT[\r][\n]"
DEBUG - << "Content-Length: 13[\r][\n]"
DEBUG - << "[\r][\n]"
DEBUG - Receiving response: HTTP/1.1 403 FORBIDDEN
DEBUG - << HTTP/1.1 403 FORBIDDEN
DEBUG - << Content-Type: text/html; charset=utf-8
DEBUG - << Server: Microsoft-IIS/7.5
DEBUG - << SPRequestGuid: b602e351-0301-4095-878c-7df1b893ef42
DEBUG - << X-SharePointHealthScore: 0
DEBUG - << X-Forms_Based_Auth_Required: 
http://testofebt.sharepoint.com/_forms/default.aspx?ReturnUrl=/_layouts/Error.as
px
DEBUG - << X-Forms_Based_Auth_Return_Url: 
http://testofebt.sharepoint.com/_layouts/Error.aspx
DEBUG - << X-MSDAVEXT_Error: 917656; Access denied. Before opening files in 
this location, you must first browse to the web site and select the option to 
login automatically.
DEBUG - << X-Powered-By: ASP.NET
DEBUG - << MicrosoftSharePointTeamServices: 14.0.0.6106
DEBUG - << P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI 
TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
DEBUG - << Date: Fri, 23 Dec 2011 03:05:50 GMT
DEBUG - << Content-Length: 13
DEBUG - Connection can be kept alive indefinitely
DEBUG - << "403 FORBIDDEN"
DEBUG - Released connection is reusable.
DEBUG - Releasing connection 
[HttpRoute[{}->http://testofebt.sharepoint.com]][null]
DEBUG - Pooling connection 
[HttpRoute[{}->http://testofebt.sharepoint.com]][null]; keep alive indefinitely
DEBUG - Notifying no-one, there are no waiting threads
Exception in thread "main" com.googlecode.sardine.impl.SardineException: 
Unexpected response (403 FORBIDDEN)
    at com.googlecode.sardine.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:49)
    at com.googlecode.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:40)
    at com.googlecode.sardine.impl.handler.MultiStatusResponseHandler.handleResponse(MultiStatusResponseHandler.java:1)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:945)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:919)
    at com.googlecode.sardine.impl.SardineImpl.execute(SardineImpl.java:693)
    at com.googlecode.sardine.impl.SardineImpl.list(SardineImpl.java:345)
    at com.googlecode.sardine.impl.SardineImpl.list(SardineImpl.java:331)
    at SardineDemo.main(SardineDemo.java:41)

Original comment by chen...@ustcsoft.com on 23 Dec 2011 at 3:08

GoogleCodeExporter commented 9 years ago
http://msdn.microsoft.com/en-us/library/hh147177.aspx

sharepoint Online (office 365 ) may need : Auth cache set in the context
but how to get FedAuth Cookie ,rtFA Cookie

Original comment by chen...@ustcsoft.com on 23 Dec 2011 at 9:41

GoogleCodeExporter commented 9 years ago
Looks like you will have to implement your own proprietary authentication 
handler. You can SardineImpl to use your own client instance and attach a 
credentials provider that is able to provide the tokens needed.

Original comment by dkocher@sudo.ch on 23 Dec 2011 at 1:51