A basic Java library and command-line tool to manage files hosted on sharepoint (either directly or from teams). Only files and folders are supported, everything else is out of scope.
Both legacy user/password authentication and OAuth2 with client id are supported.
After Sharepoint ACS deprecation and new Microsoft Entra ID, you must have the proper set of permission to read/write files. Depending on those permissions, you may use Sharepoint API or Graph API.
java -jar sharepoint-client.jar url site auth_method login password action [options]
Possible authentication methods are:
- user: use user and password credentials (not supported for Graph API)
- api: use OAuth2 with client id and secret
Possible API are:
- sharepoint: Use Sharepoint API
- graph: Use Graph API (default on command-line)
Possible actions are:
- upload-folder
- delete-folder
- list-folders
- list-files
- download
Some examples:
java -jar sharepoint-client.jar https://xxx.sharepoint.com ProductDevelopment user you@company.com password upload-folder /tmp/folder "Software" NewFolder
java -jar sharepoint-client.jar https://xxx.sharepoint.com ProductDevelopment api clientId clientSecret delete-folder "Software/NewFolder"
Please note that upload-folder isn't recursive, and expects a flat file hierarchy.
Add the nanalysis-public maven repository:
<repositories>
<repository>
<id>nanalysis-public</id>
<url>https://raw.githubusercontent.com/nanalysis/maven-repository/public/</url>
</repository>
</repositories>
Then declare the dependency:
<dependency>
<groupId>com.nanalysis</groupId>
<artifactId>sharepoint-client</artifactId>
<version>2.0</version>
</dependency>
See ManualTests class for examples.
Information about OAuth2 was found there:
Information on Microsoft Graph API:
This library is published under the GNU GPL v3, and an internal proprietary license for use in Nanalysis, RS2D and OneMoonScientific projects.
- 2.0: Update OAuth2 authentication following ACS removal, support Graph API which becomes command-line default, move to JDK17.
- 1.4: Add list files/folders and download commands.
- 1.3: Chunked upload for big files.
- 1.2: OAuth2 support.
- 1.1: Add log on folder deletion, error exit one exception.
- 1: First version of Sharepoint client.