π Welcome to the easy to use code base for consuming sharepoint. This code base should help you quickly get it up and running for consuming sharepoint from Azure.
While working on this we found out there is some core concepts you need to understand about Sharepoint in Azure.
The Microsoft identity platform implements the OAuth 2.0 authorization protocol. OAuth 2.0 is a method through which a third-party app can access web-hosted resources on behalf of a user. Any web-hosted resource that integrates with the Microsoft identity platform has a resource identifier, or Application ID URI.
- .default - To use the authentication based off the application
If you need to look specifically at the routes to call, you can check them Here
- Python 3.7
βββ config
β βββ config.yaml
β βββ oauth_settings.yaml
βββ sharepoint_graph
β βββ sites.py
βββ util
β βββsettings.py
βββ main.py
main.py
TENANT_ID = '' #Just the tenant ID
SITE_ID = '' #The site id for the sharepoint site
CLIENT_ID = '' #The client id that you get from azure or your sharepoint site
CLIENT_SECRET = '' # #The client secret that you get from azure or your sharepoint site
GRANT_TYPE = 'client_credentials' #The authentication that is being used for getting a token
LIST_ID = '' #The list id of where you would want to get the sharepoint lists
sharepint_graph/sites.py
graph_url = 'https://graph.microsoft.com/v1.0'
SITES = '/sites'
LISTS = '/lists'
HOST_NAME = 'azure.sharepoint.com'
site_lists_dict = None
COLUMNS = '/columns'
HOST_NAME = ''
SITE_ID = ''
WEB_ID = ''
LIST_ID = ''
First we need to make a call to get our token. You can see how to get a token in the main.py code
https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token
Now that you have a token, you just need to create the endpoint base then call the sites and start pulling the data as you can see here.
https://graph.microsoft.com/v1.0/sites/{{hostname}},{{SITE_ID}},{{WEB_ID}}/
This is a simple python module that can you run it as a lib (just need to make this into a setup.py) or copy this code to your location.
pip install -r requirements.txt
You need to start off first doing a virtual env. On mac it is:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Running the code is very simple, just run python -m main and if everything is set, you can start calling the functions.
Please refer to Contribution Guidelines for guidance on contributing to this project.