👷‍♂️
Work
  • 💻SNOW
    • Catalog Forms
    • Knowledge Base
  • ☁️Azure
    • Graph Permissions
    • App Registration Auths
      • Postman
      • Graph ROPC Federated Account
        • MSAL UsernamePasswordCredential
        • Java
        • Python
        • C#/VB code Auth
      • Powershell
      • Java Auth x EWS
      • Python Auth x Sharepoint
      • C# Auth x Sharepoint
    • MFA
    • Dynamic Group
    • AAD Device Pending
    • O365 Device Enrollment
    • AAD Device Troubleshoot
    • AAD Mobile Troubleshooting
    • ADO Service Principal
    • External B2B
    • VLSC Admin
    • PowerBI Session Timeout
    • SSO issues
  • 🔓OKTA
    • SVC Account
    • OKTA Integration
    • Access Issues
  • 👷‍♂️Workday
    • Account Lifecycle
    • Coupa
  • 📨O365
    • OOF of Distribution List
    • Mailbox Recovery
    • Mailbox Existence
  • 🦄Misc
    • Windows Terminal
    • Google Auth Export
    • MS Teams Issues
  • 🌥️Cloud Stuff
    • 🚀Benchmarking
      • Vultr
    • 💳Cloud Server
    • ♻️Email and Spams
  • 🔬Open Source
    • Pending
      • Matrix/Synapse
      • Huginn
      • ChangeDetection
    • Tested
      • Codex Docs
      • Ghost Blog
      • n8n Automation
Powered by GitBook
On this page
  1. Azure
  2. App Registration Auths

Python Auth x Sharepoint

PreviousJava Auth x EWSNextC# Auth x Sharepoint

Last updated 2 years ago

Pre-requisites from

  • python3 -m pip install azure-identity

  • python3 -m pip install msgraph-core

Sharepoint Site Resource Type

Python AZ Identity Packages (See usernamepasswordcredentials)

from azure.identity import UsernamePasswordCredential
from msgraph.core import GraphClient
# Using InteractiveBrowserCredential for demonstration purposes.
# There are many other options for getting an access token. See the following for more information.
# https://pypi.org/project/azure-identity/
credential = UsernamePasswordCredential(client_id='a12fd75f-2b0b-42ce-ad03-750bb62b87f0',username='RITM@nmicrosoft.com',password='ALSsgdf21',tenant_id='bc876b21-f134-4c12-a265-8ed26b7f0f3b')
client = GraphClient(credential=credential)


##################
# [0] Auth test
#       #result = client.get('/me')
# [1] Graph Explorer to test queries
#       https://developer.microsoft.com/en-us/graph/graph-explorer
# [2] Example to visit default Sharepoint site
#       https://jabil.sharepoint.com/
result = client.get('/sites/d1acf547-1324-406b-82bb-c06ecd6c5a66/lists')
##################

#result = client.get(/sites/4637ce2f-2cba-4163-a038-e5bec3826b0e/drive/items/f685c3ea-b38e-4d4b-8290-761c57c11cbe35/content)
# result = client.get('/me/drive/root')
# result = client.get('/sites/4637ce2f-2cba-4163-a038-e5bec3826b0e/lists')
# result = client.get('/sites')
# result = client.get('/sites/{site-id}/lists/{list-id}/items')
print(result.json())
☁️
Microsoft lab sample
https://learn.microsoft.com/en-us/graph/api/resources/site?view=graph-rest-1.0
https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python