Skip to main content

sharepointsimple is a python library to upload and download the files from SharePoint

Project description

sharepointsimple

sharepointsimple is a python library to upload and download the files from SharePoint.
It uses SharePoint REST services to perform CRUD operations and runs on SharePoint's app-only principals using App-Only model for OAuth authentication.

Pre-Requisites

Client ID, Client Secret and Tenant ID is required to communicate with your SharePoint.

Read this documentation to generate Client ID, Client Secret and Tenant ID.

Note:
You must have Owner access to a SharePoint site to generate Client ID and Client Secret

Installation

pip install sharepointsimple

Methods

sharepointsimple has four methods

Usage

Step 1 ::

connect

import sharepointsimple as ss

ss.connect(clientid = 'Your-ClientID',
           clientsecret = 'Your-ClientSecret',
           tenantid = "Your-TenantID", # A method to get TenantID is at end of the page
           domain = 'yourCompany',     #Eg: As in "yourCompany.sharepoint.com"
           SP_sitename = 'yourSharePointSite'
           )

Step 2 (1) ::

download

ss.download(local_path = "/Users/Folder",
            SP_path = "Folder/SubFolder",           #SP path starts from the root folder directly inside a SP Sites
            files_to_download = "file1.xlsx,file2.txt" #(Optional) Remove this to download all the files in SP folder
           )
  • Multiple file names should be given in comma seperated as a single string (list is also accepted)
  • Remove argument filename if you want to download all the files in the folder i.e: SP_path
  • You need not include 'Shared Documents', a default folder, under which all the files are present in

Step 2 (2) ::

upload

ss.upload(SP_path = "Folder/SubFolder",
          local_path = "/Users/Folder",
          files_to_download = "file1.xlsx,file2.txt", #(Optional) Remove this to upload all the files in local system
         )

Hola! You are done


Optional Step ::

create_folder

create_folder is an optional method if you want to create a new folder
It is NOT necessary to call this method before uploading a file to a non-existing folder in SP
upload method already has a built in functionality to create a folder if it doesn't exist in SP site

ss.create_folder(SP_path = "Folder/SubFolder")

Folder will be created in the SharePoint path
It will not create a new folder, if the folder is already present

License

MIT
Hit it, it costs nothing! :blush:


How to get Tenant ID

  1. Open any browser
  2. Type in the address bar, https://login.microsoftonline.com/[YourCompany].onmicrosoft.com/.well-known/openid-configuration\ Replace "[YourCompany]" with your organisation name
  3. In the response, look at the key named "token_endpoint"
  4. Your Tenant ID is, after https://login.microsoftonline.com/ and before /oauth2/token\

Example:
In the below response, Tenant ID is, 05200b0x-xxx2-4xx4-x25x-020ab5865xx3
***"token_endpoint":"https://login.microsoftonline.com/05200b0x-xxx2-4xx4-x25x-020ab5865xx3/oauth2/token"***\

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sharepointsimple-0.1.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharepointsimple-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file sharepointsimple-0.1.2.tar.gz.

File metadata

  • Download URL: sharepointsimple-0.1.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.8

File hashes

Hashes for sharepointsimple-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d2bf1fc93c3c02a79709805d578a878ab311afcd8a8659fe7a72022eefb76034
MD5 b64376a021f9a6f9a0de4e98efbfe583
BLAKE2b-256 7c99754f78db90f45cf8626e76767d887a0a841b950d2753cf62f77e8ad09b13

See more details on using hashes here.

File details

Details for the file sharepointsimple-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sharepointsimple-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.8

File hashes

Hashes for sharepointsimple-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac47077fc9015e59e575c8f0d16f587781ed32440ee5f4fa38969cd8b640dd0
MD5 1a8dde5066911c76a68624ed83a315c9
BLAKE2b-256 ef55774e31ff95d5fa89d4154c0a30a9fb9347e7cb8b3fa58baa9df2e1b0aa75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page