function main_v26
Diagnostic function that tests SharePoint tenant configuration by checking Microsoft Graph API access and provides recommendations based on the results.
/tf/active/vicechatdev/SPFCsync/check_tenant_config.py
219 - 245
simple
Purpose
This function serves as the main entry point for a diagnostic tool that verifies whether Microsoft Graph API or SharePoint REST API can be accessed with app-only authentication. It tests Graph API connectivity, displays results with visual indicators (emojis), provides admin instructions, and recommends next steps based on whether Graph API access is successful. This is useful for troubleshooting SharePoint sync application authentication issues at the tenant level.
Source Code
def main():
"""Main diagnostic function."""
print("SharePoint Tenant Configuration Checker")
print("=" * 50)
# Test if Graph API approach works
graph_works = test_graph_api_access()
if graph_works:
print("\nš SUCCESS: Microsoft Graph API works!")
print("This means we can use Graph API instead of SharePoint REST API.")
print("I can modify the sync app to use Graph API as a workaround.")
else:
print("\nā Microsoft Graph API also has issues.")
print("This confirms it's a tenant-level app-only authentication problem.")
provide_admin_instructions()
print("\n" + "=" * 60)
print("š” **RECOMMENDATION**")
print("=" * 60)
if graph_works:
print("Since Graph API works, I can create a Graph-based version")
print("of the sync application that bypasses SharePoint REST API issues.")
else:
print("You need SharePoint admin to enable app-only authentication")
print("at the tenant level before the sync application will work.")
Return Value
This function does not return any value (implicitly returns None). It performs side effects by printing diagnostic information, test results, and recommendations to stdout.
Dependencies
requestsjson
Required Imports
import requests
import json
Usage Example
# Assuming test_graph_api_access() and provide_admin_instructions() are defined
# Example standalone execution:
if __name__ == '__main__':
main()
# Or call directly:
main()
# Expected output:
# SharePoint Tenant Configuration Checker
# ==================================================
# [Test results from test_graph_api_access()]
# š SUCCESS: Microsoft Graph API works!
# [Additional instructions and recommendations]
Best Practices
- This function depends on test_graph_api_access() and provide_admin_instructions() functions which must be defined before calling main()
- The function is designed for interactive CLI use and prints directly to stdout rather than returning values
- Should be called as the entry point of a diagnostic script, typically in an if __name__ == '__main__': block
- The function provides user-friendly output with visual indicators (emojis) which may not render correctly in all terminal environments
- Consider wrapping the function call in try-except blocks to handle potential exceptions from the dependent functions
- This is a diagnostic tool and should not be used in production code paths
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v27 81.9% similar
-
function main_v22 80.7% similar
-
function test_graph_api_access 79.9% similar
-
function quick_test 78.3% similar
-
function main_v24 78.1% similar