This Python script helps developers and support engineers inspect and validate Microsoft Graph sharing links.
- Automatically acquires an app-only access token using MSAL.
- Encodes and decodes sharing URLs to and from Graph-compatible
shareIdformat. - Classifies shared resources (e.g., document, list item) based on URL patterns.
- Calls the appropriate Microsoft Graph API endpoint (
/driveItemor/listItem) based on classification. - Handles throttling (HTTP 429) and transient errors with retry logic.
- Prints detailed metadata and item responses for inspection.
- Python 3.7+
requestsmsal
Update the TENANT_ID, CLIENT_ID, and CLIENT_SECRET in the script. Input any sharing URLs you would like to test. Example:
shared_urls = [
"https://yourdomain.sharepoint.com/:t:/s/ExampleSite/ExampleFile.txt",
"https://yourdomain.sharepoint.com/sites/yoursite/Lists/yourlistitem"
]
Then run:
python testShares.pyInstall dependencies:
pip install requests msal