Categories:

Download SharePoint Online Files using MAC CURL Command

MAC SharePoint users were downloading the files from SharePoint 2007 Document Libraries using the CURL command but the same is not working after migrating the SharePoint 2007 sites to SharePoint Online(SPOL).

Example:

Cause:
SharePoint Online uses claims based authentication and direct NTLM based curl commands are not allowed.

Resolution:
SPOL allows remote applications to call the REST API with user impersonation. This article demonstrates how to access SPOL REST API and download the files from a tenant using Apple Bash Script and Curl commands. However, outside of .NET the authentication piece is not so straightforward. App authentication solves this issue for registered apps but in this document you will see how remote user authentication can be achieved, regardless of platform.

The below diagram illustrates the HTTP requests which need to be made in order to authenticate SharePoint Online.

Applies To:
Office 365 Tenant connected with Active Directory Federated Service(ADFS) and MAC OS

Execution Steps:

Leaderboard_CDR

 I. Download the Download.sh file from here
II. Open Download.sh file in a text editor(TextWrangler/TextMate) and update the UserName (Line #4) and Password (Line #5).

Note: The UserName & Password provided should have access to download the file from SharePoint Online.

I. To download the file from a different SharePoint Online site/library/folder/file where the account has access, change the values of EndPoint(Line #6) and FileServerRelativeUrl(Line #7) values.
II. Save the Download.sh file
III. Open Terminal (command line tool) and go to the path where Download.sh file is saved
IV. Execute the following command to convert the Download.sh file executable chmod 700 Download.sh
V. Run the script using just the name of the script(Example : ./ Download.sh)
VI. If all goes well, you should be able to see the downloaded file in the output path given in OutputFilePath(Line #9).

Failure Chances:

I. UserName and Password provided might be wrong
II. Access denied from SharePoint Online for the UserName and Password provided
III. Provided Site/Document Library/Folder/File is not available in SharePoint Online or wrong
IV. Text Editor might have changed or corrupted the Download.sh file while saving

I hope this article will give back a little to the community that has helped me. Sharing is Caring.

Sharing is Caring!

Leave a Reply

Your email address will not be published. Required fields are marked *