function main_v44
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() being defined elsewhere in the codebase
- The function is designed for interactive CLI use with formatted console output
- Should be called as the main entry point of the diagnostic script
- Does not handle exceptions - ensure dependent functions have proper error handling
- Uses emoji characters which may not display correctly in all terminal environments
- Consider redirecting output to a file if running in environments without emoji support
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v47 81.9% similar
-
function main_v43 80.3% similar
-
function test_graph_api_access 79.9% similar
-
function quick_test 78.3% similar
-
function main_v35 77.8% similar