How to Subscribe to SharePoint RSS Feeds Without NTLM Authentication
Save the Planet
For the past couple of months, I have been rebuilding an internal tool we use at SEP called Planet.
This tool aggregates blog posts from many sources, including our official SEP blog, personal blogs, and internal SharePoint blogs. After a recent upgrade to our SharePoint instance, Planet was in trouble! The SharePoint blogs were no longer able to be fetched, and that’s when I decided it was time for a re-write.
I built out most of the functionality during my evenings, only leaving the hardest part for this summer’s SEP: Makes hackathon, integrating with SharePoint!
Now follow me on a guided tour of my fantastically ridiculous solution. 😏
Having spent a few hours failing to authenticate with SharePoint via its NTLM authentication scheme, I figured that since Google Chrome already knows how to do that handshake, why should I learn?
After spinning up a headless browser, it wasn’t difficult to get logged into SharePoint. Chrome makes it easy to accomplish this kind of authentication by allowing you to format the URL with the login credentials included, like so https://username:email@example.com.
Chrome will extract the credentials from this URL and then perform the authentication handshake for you, allowing you to log in without having to fill in any prompts!
Downloading the feed
Now having easy access to SharePoint, let’s download the page! Sounds easy enough, right? Well, SharePoint loves to make our lives difficult and it hasn’t failed to disappoint.
It turns out that SharePoint RSS feeds come with an Extensible Stylesheet Language Transformation (XSLT), which will actually manipulate the DOM, as opposed to CSS, which is purely presentational.
But. There’s always a but.
Due to a limitation with the headless Chrome library I was using, I wasn’t able to return the asynchronous response to my application code.
As a workaround, I discovered I could replace the contents of the DOM with the response, essentially accomplishing what I wanted in the first place!
With the DOM now in the desired format, I simply downloaded the page source and voila! I had (mostly) what I wanted.
In the end, this is the function that got the job done.
These 32 lines took me about 15 hours to write, but in the end I was able to accomplish my goal: retrieving RSS feeds from SharePoint.
Experiences like this remind me that no matter how hopeless a situation feels, with enough creative thinking and perseverance, you can solve any problem that you put your mind to!
Feel free to browse the source code to see the entire application!