@windexoriginal that would be too logical for microsoft, i guess they want to track you first hehe.
found the solution:
sharepoint redirects you for the first download url and gives you the fedauth cookie in the first response.
You have to take it and the actual download location and start a new request like this when redirected:
302 ->
pdf_url |> IO.inspect()
parsed_uri = URI.parse(pdf_url)
# get the path of the real download
download_location =
headers
|> Enum.find(fn {header_name, _} -> header_name == "Location" end)
|> elem(1)
download_url =
"#{parsed_uri.scheme}://#{parsed_uri.host}#{download_location}"
fed_auth_cookie =
headers
|> Enum.find(fn {header_name, _} -> header_name == "Set-Cookie" end)
|> elem(1)
download_pdf(download_url, fed_auth_cookie)
i guess this behaviour is already baked in to the python request lib