The Client Side Object Model – Help with Headless Authentication in SharePoint Online
To fill a gap in the currently available SharePoint Office 365 development help with regard to the Client Side Object Model (CSOM), Chris Johnson has a helpful pair of articles found in “Authentication with SharePoint Online and the Client Side Object Model” and “Part 2: “Headless” Authentication with SharePoint Online and the Client Side Object Model.”
The first part of the two-part series explains how to authenticate and get data from SharePoint Online in a client application such as a Windows application. The article explains how to pop up a browser in a dialog window to allow the user to enter Office 365 login and password and then attach the SharePoint CSOM authentication cookies to query your SPO site. This is a great solution, but does not work so well if there is no user present, such as when your client code is a service.
“To deal with this scenario the code needs to effectively BE the user and login on their behalf. To do this this sample queries the Office 365 STS directly using the Windows Identity Foundation (WIF). WIF helps with managing the security tokens and requests to the STS.”
There is a download attached to the article which you can use to do this, but before you can run it, you will need to install WIF Runtime and CSOM Redistributable. The sample given uses WIR to login the user with the Office 365 STS, extracts the authentication coolies from the response, constructs a CookieContainer and attaches it to the CSOM web request, and calls your SPO site and returns the Title property of the site. For more detail and the download, click on the Part 2 section of the original article.
Office 365 is an exciting development in the world of SharePoint. Whether you are using SharePoint in the cloud or on-premise, Smartlogic offers taxonomy management and governance fully integrated to SharePoint, which prevents the chaos caused when any user can modify shared taxonomies.
July 18, 2011