Package: sharepointcli
Installation$pipinstallsharepointcliConfigurationTo allow authentication you first need to register your application.
For steps on how to configure the app in the Azure portal, seeRegister your appFor general use, thespo configurecommand is the fastest way to set up SharePoint CLI.
When you enter this command, the CLI prompts you for the following configurations:SharePoint domainApplication (client) IDApplication (client) secretThespo configurecommand stores the credentials in the credentials file.
You can configure configure multiple credentials for different SharePoint domains.
Example:$spoconfigureSharePoint domain (e.g. example.sharepoint.com):Tenant Id: db3fe96d-1b57-4119-a5fd-bd139021158dClient Id: fa3ecc92-5994-475e-a647-1f81931aac43Client Secret: ~vaXZkx&836mH56FymE6Gx7j$t&JT.-5emVisit the following url to give consent:https://login.microsoftonline.com/db3fe96d-1b57-4119-a5fd-bd139021158d/oauth2/v2.0/authorize?response_type=...Paste the authenticated url here:https://login.microsoftonline.com/common/oauth2/nativeclient?code=....Authentication Flow Completed. Oauth Access Token Stored. You can now use the API.Authenticated!The credentials take precedence in the following order:Command line optionsEnvironment variablesCredentials fileCommand line optionsYou can use the following command line options to override the default configuration settings.--client_idSpecifies the Client Id.--client_secretSpecifies the Client Secret--tenant_idSpecifies the Tenant IdEnvironment variablesEnvironment variables provide another way to specify credentials, and can be
useful for scripting.
If you specify an option by using a parameter on the command line, it
overrides any value from the environment variables or the configuration file.The CLI supports the following environment variables:SPO_HOMESpecifies the home directory.
The default path is "~/.spo".SPO_CREDENTIALS_FILESpecifies the location of the file that the CLI to store credentials.
The default path is "~/.spo/credentials".SPO_CLIENT_IDSpecifies the Client Id.SPO_CLIENT_SECRETSpecifies the Client SecretSPO_TENANT_IDSpecifies the Tenant IdCredentials fileThe CLI stores sensitive credential information in a file named credentials in a directory named.spoin your home directory.
For example, the file generated withspo configurelooks similar to the following:[example.sharepoint.com]client_id=fa3ecc92-5994-475e-a647-1f81931aac43client_secret=~vaXZkx&836mH56FymE6Gx7j$t&JT.-5emtenant_id=db3fe96d-1b57-4119-a5fd-bd139021158dUsageauthenticatePerforms the OAuth authentication flow using the console.Usage$spoauthenticate[domain]configureConfigures credentials.Usage$spoconfigure[domain]cpCopying a local file to SharePoint.Usage$spocp<LocalPath><SharePointUrl>orcp<SharePointUrl><LocalPath>ExamplesThe following cp command copies a single file to a specified site:$spocptest.txt'https://example.sharepoint.com/sites/example/Shared documents/test.txt'upload: test.txt to https://example.sharepoint.com/sites/example/Shared documents/test.txtThe following cp command copies a single file from a SharePoint site:$spocp'https://example.sharepoint.com/sites/example/Shared documents/test.txt'test.txtdownload: https://example.sharepoint.com/sites/example/Shared documents/test.txt' to test.txthelpDisplays commands help.Usage$spohelp[topic]lsLists files and folders.Usage$spols[options]<SharePointUrl>Options-mtime n  File's status was last changed n*24 hours ago. ('+n' more than n, 'n' exactly n, '-n' less than n)Examples$spols'https://example.sharepoint.com/sites/example/Shared documents/*.txt'mkdirCreates folder.Usage$spomkdir<SharePointUrl>rmDeletes files.Usage$sporm[options]<SharePointUrl>Options-mtime n  File's status was last changed n*24 hours ago. ('+n' more than n, 'n' exactly n, '-n' less than n)Examples$sporm'https://example.sharepoint.com/sites/example/Shared documents/*.txt'rmdirDeletes folder.Usage$spormdir<SharePointUrl>versionPrints the version number.Usage$spoversionTestsTo run the unit tests:create the ~/.spo/credentials credentials fileexport your SharePoint test site url as environment variable 'SITE'$spoconfigureSharePoint domain (e.g. example.sharepoint.com):Tenant Id: db3fe96d-1b57-4119-a5fd-bd139021158dClient Id: fa3ecc92-5994-475e-a647-1f81931aac43Client Secret: ~vaXZkx&836mH56FymE6Gx7j$t&JT.-5em$expotSITE='https://example.sharepoint.com/sites/example/Shared documents/test folder'$maketestLicenseThis project is licensed under the MIT license.LinksProject home page (GitHub)O365SharePlumOffice 365 CLI