Skip to content

Instantly share code, notes, and snippets.

@mhanberg
Created August 18, 2018 23:51
Show Gist options
  • Save mhanberg/32e35f6faa69d4bf3bb4de29c8fc06bd to your computer and use it in GitHub Desktop.
Save mhanberg/32e35f6faa69d4bf3bb4de29c8fc06bd to your computer and use it in GitHub Desktop.
How to Subscribe to SharePoint RSS Feeds Without NTLM Authentication
# Elixir source code
def get(%Rss{is_sharepoint: true, url: url}) do
match = Regex.named_captures(~r{(?<protocol>http://|https://)(?<sharepoint_url>.*)}, url)
url_with_creds =
match["protocol"] <> System.get_env("SHAREPOINT_CREDS") <> "@" <> match["sharepoint_url"]
Logger.info("Fetching sharepoint feed with #{url_with_creds}")
try do
{:ok, session} = Wallaby.start_session()
feed =
session
|> visit(url_with_creds)
|> execute_script("""
fetch("#{url}")
.then(r => r.text())
.then(t => document.querySelector("html").innerHTML = t);
""")
|> page_source
session
|> Wallaby.end_session()
feed
rescue
e ->
Logger.error("Error fetching sharepoint feed: #{inspect e}")
""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment