Insert into SharePoint List using Python

To get past SharePoint authentication, we need to get ClientID and access key,
Open this link to register new App

In order to access this registration page, you may need to have an access collection administrator and above.

Click on generate for both Client id and client secret

Next step is to grant permission to the newly created principal (App)
In order to access the page, go to the link

Make a note of the client id that was generated in step 1, Paste the client id and click on “Lookup”

<AppPermissionRequests AllowAppOnlyPolicy="true">
  <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />

Paste the above XML in Permission request xml

Click on “Trust it” , now this should give access to the sharepoint

create a new list library “Testing” with two columns “Title” and “Status” in sharepoint
install office365 client library
pip install Office365-REST-Python-Client

Below code will insert values into Title and Status field in Testing list library


import json
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request import ClientRequest
from office365.runtime.utilities.request_options import RequestOptions
from office365.sharepoint.client_context import ClientContext

app_settings = {
        'url': "https://<sharepoint link>/",
        'client_id': "489e83b7-d47b-4d08-abce-02be0fa849c2",
        'client_secret': "jNSKgOJCPwKMnt+GUIZqOPezaD5u7S0x/fUtjtX0Mys=",
context_auth = AuthenticationContext(url=app_settings['url'])
context_auth.acquire_token_for_app(client_id=app_settings['client_id'], client_secret=app_settings['client_secret'])
ctx = ClientContext(app_settings['url'], context_auth)

list = ctx.web.lists.get_by_title("Testing")
list.add_item({'Title': "Testing", 'status': "Pending"})

“Hello world” using python in Red hat

Before installing python on the Linux platform, you may have to install zlib package,

$ yum install zlib-devel

if any permission issue, then 
$ sudo yum install zlib-devel
Download python releases from, you can choose the release version according to your need

$ wget
unzip the downloaded file using the following command
$ tar xf Python-3.8.6.tgz
Change the directory to python directory

 $ cd Python-3.*
run the ./configure tool to prepare the build
$ run the ./configure tool to prepare the build
now using make command , start to build python
$ make
finally you can install python using the below command,
$ make install

if you face any permission issue, then use sudo

$ sudo make install

If you need to run multiple python releases in your platform, you have to use the below command, so it will not overwrite the existing python release
$ make altinstall
$ vim
# helloworld program
print('Hello world')

press “esc” and type 😡 (save and exit)

now execute the python code

$ python