44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Script to force Microsoft re-authentication for SharePoint access.
|
|
This will disconnect the existing connection and provide a new login URL.
|
|
"""
|
|
|
|
import requests
|
|
import json
|
|
|
|
# Configuration
|
|
BASE_URL = "http://localhost:8000" # Adjust if your server runs on different port
|
|
CONNECTION_ID = "cc62583d-3a68-44b6-8283-726725916a7e" # From the logs
|
|
|
|
def force_reauth():
|
|
"""Force Microsoft re-authentication by disconnecting and providing new login URL."""
|
|
|
|
print("🔄 Forcing Microsoft re-authentication for SharePoint access...")
|
|
|
|
# Step 1: Disconnect existing connection
|
|
print(f"1. Disconnecting connection {CONNECTION_ID}...")
|
|
disconnect_url = f"{BASE_URL}/api/connections/{CONNECTION_ID}/disconnect"
|
|
|
|
try:
|
|
response = requests.post(disconnect_url)
|
|
if response.status_code == 200:
|
|
print("✅ Connection disconnected successfully")
|
|
else:
|
|
print(f"❌ Failed to disconnect: {response.status_code} - {response.text}")
|
|
return
|
|
except Exception as e:
|
|
print(f"❌ Error disconnecting: {e}")
|
|
return
|
|
|
|
# Step 2: Get new login URL
|
|
print("2. Getting new Microsoft login URL...")
|
|
login_url = f"{BASE_URL}/api/msft/login?state=connection&connectionId={CONNECTION_ID}"
|
|
|
|
print(f"\n🔗 Please visit this URL to re-authenticate with SharePoint permissions:")
|
|
print(f" {login_url}")
|
|
print("\nAfter re-authentication, the JIRA sync should work with SharePoint access.")
|
|
print("\nNote: The new token will include Sites.ReadWrite.All and Files.ReadWrite.All scopes.")
|
|
|
|
if __name__ == "__main__":
|
|
force_reauth()
|