SharePoint is a strong platform for collaboration and doc administration, extensively utilized in organizations to streamline workflows and enhance productiveness.
To work together with SharePoint assets programmatically, builders usually use entry tokens.
On this weblog, we are going to discover the way to learn SharePoint lists utilizing delegated entry tokens, which permits purposes to entry assets on behalf of a person, making certain safe and managed entry.
You will discover lot of code on web primarily associated to Powershell utilizing PNP, Graph or CSOM however for python you discover largely with workplace 365 relaxation shopper.
I’m sharing the instance utilizing customary requests library that we use for accessing any relaxation API software and that too with delegated permissions.
Assumption is APP is already registered in Azure AD and has following delegated permissions.
Modules required:
- os
- Requests – For Relaxation API calls
- Json – for changing the request output to json format
- DPAPI – For Password encryption/Decryption
Script to obtain:
https://github.com/VikasSukhija/Python
Now replace the script variables asper your surroundings
Additionally, replace the ReqTokenbody à Username parameter
Now when you’ll run the script it is going to immediate you for 3 issues for first time solely:
- ClientID of the Registered Utility
- Password for the UserName (Delegated account)
- Secret of the Registered Utility
It should retailer all these in encrypted type in config folder after first run:
After that python will get the entry token and begin studying the SharePoint on-line checklist and acquire all gadgets in Coll_listItems checklist.
You’ll be able to improve this code additional and do no matter operations you need to carry out on the checklist gadgets.
I simply need to present how we are able to cope with SharePoint checklist utilizing delegated tokens.
Thanks for studying and downloading…
Tech Wizard