Pergunta

I'm looking to download multiple files from a SharePoint site and upload them to another cloud provider. I've done some testing and it looks like I only have to add the cookie to the cookie container on the HttpWebRequest. When setting the cookie expiry date

Expires = DateTime.Now.AddSeconds(30)

The download throws a 403 which is expected. I was hoping I could set for it for 5 days. I guess the question is, is there max expiry date that can be set for the SPOIDCRL cookie? Will I need to re authenticate at any point?

Foi útil?

Solução

According to SharePointOnlineCredentials class from SharePoint Online Client Components SDK the expiry date for authentication cookie (SPOIDCRL) should be set to 1 hour

The following example demonstrates how to provide SPOIDCRL HTTP header in order to perform request authentication in SharePoint Online/Office 365:

var request = (HttpWebRequest)WebRequest.Create(endpointUri);
var credentials = new SharePointOnlineCredentials(userName,securePassword);
var authCookie = credentials.GetAuthenticationCookie(webUri);
request.Headers.Add(HttpRequestHeader.Cookie, authCookie);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top