Upload local files into sharepoint and print the resulting url to stdout
- php 8.1+
Please use the .deb packages. The repository is availble:
echo "deb http://repo.vitexsoftware.com $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
sudo wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.com/keyring.gpg
sudo apt update
sudo apt install file2sharepointRun the interactive wizard to create an Azure App Registration and write a .env file:
bin/azure-setup-wizard # writes .env in the project root
bin/azure-setup-wizard /path/to/.env # writes to a custom path
make setup-wizard # shorthand via MakefileThe wizard will:
- Ask for the SharePoint tenant, site, and library/folder.
- Let you choose between App registration (Client ID + Secret, recommended for automation) or User credentials (Username + Password).
- For App registration it optionally uses the Azure CLI
to create the app, assign the Microsoft Graph
Sites.Selectedapplication permission, grant the app access to the target site, and generate a client secret automatically. - Write the resulting credentials to the
.envfile (mode600).
Required Azure permission for client-credentials mode
Resource: Microsoft Graph (00000003-0000-0000-c000-000000000000)
Application role:Sites.Selected
Admin consent must be granted by a Global Administrator, and the app must additionally be granted access to the specific site viaPOST /sites/{siteId}/permissions(the wizard does this automatically).Client-credentials auth authenticates via the modern Entra ID v2
client_credentialsflow, not the legacy SharePoint "App-Only via Azure ACS" flow (AllSites.Writeunder the classic SharePoint API resource00000003-0000-0ff1-ce00-000000000000) — Microsoft fully retired ACS for all tenants on 2026-04-02, with no extension possible (details). Confirmed empirically: ACS still issues a syntactically valid token, but SharePoint Online now rejects it on the real REST call regardless of credential correctness.
file2sharepoint <source/files/path/.> <Sharepoint/dest/folder/path/> [/path/to/config/.env]
Login based auth
OFFICE365_USERNAME=me@company.tld
OFFICE365_PASSWORD=xxxxxxxxxxxxxxClientID based auth
OFFICE365_CLIENTID=78842b49-651d-516e-0f2g-f979956aa620
OFFICE365_CLSECRET=8FR8Q~3Rab4-5o8dVd~1vDRId9oYiqEtMJB.Ucb2Destination options
OFFICE365_TENANT=yourcompany
OFFICE365_SITE=YourSite
SHAREPOINT_LIBRARY='Shared documents/files'Into configuration file .env please put ClientID OR Login/Password values.
This application uses the following exit codes:
0: Success1: General error