In Office 365 how do I get a direct download link for an Excel document stored in One Drive for Business?
Thanks to finding out OneDrive for Business is actually a re-branded Sharepoint 2013 and an answer in Sharepoint@SE I managed to get a link for programmatic download of a document.
One way to achieve is to right click on the document in the web GUI and take the URL there. It didn't work for me as this URL required authentication, but...
Taking the prefix of the URL e.g.
https://acmeacme.sharepoint.com/personal/myname/_layouts/15/download.aspx?SourceUrl=
and the "usual" URL generated as guest link
https://acmacme.sharepoint.com/personal/myname/_layouts/15/guestaccess.aspx?guestaccesstoken=123123%3d&docid=123123
and concatenating them turned out to work like a charm:
wget https://acmeacme.sharepoint.com/personal/myname/_layouts/15/download.aspx?SourceUrl=https://acmacme.sharepoint.com/personal/myname/_layouts/15/guestaccess.aspx?guestaccesstoken=123123%3d&docid=12312
All I needed to do was change the Edit Link slightly. Just replace guestaccess.aspx
with download.aspx
.
Just to add to this thread (which pointed me in the right direction - thanks!), when trying as described above I got a 403 FORBIDDEN message when trying to download, and a Office 365 login on pasting into a browser.
To resolve I copied the guestaccesstoken=... part of the second URL and made it a parameter of the first URL also.
This then authenticated fine and the download worked a treat.
Thanks! Steve