From 9841e59e18544fda5ff8ee3ec9963bca8f98ebe4 Mon Sep 17 00:00:00 2001 From: Oli Passey Date: Fri, 24 Jan 2025 16:56:34 +0000 Subject: [PATCH] aio fix --- aio.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/aio.py b/aio.py index 96ecae7..9eb928a 100644 --- a/aio.py +++ b/aio.py @@ -1,13 +1,13 @@ import os -from dotenv import load_dotenv import logging import json -import msal -import requests import smtplib from email.mime.text import MIMEText from email.utils import formataddr from datetime import datetime, timezone +from dotenv import load_dotenv +import requests +import msal # Load environment variables load_dotenv() @@ -47,7 +47,6 @@ def get_app_registrations(): return [] # Fetch app registrations with owners - # Updated URL to include both app registration and owner data graph_url = ( "https://graph.microsoft.com/v1.0/applications" "?$select=id,appId,displayName,passwordCredentials" @@ -63,10 +62,6 @@ def get_app_registrations(): response = requests.get(graph_url, headers=headers) response.raise_for_status() - # Debug log the raw response - #logging.info(f"API Response Status: {response.status_code}") - #logging.debug(f"API Response: {response.text[:1000]}...") # First 1000 chars - app_registrations = response.json().get('value', []) logging.info(f"Fetched {len(app_registrations)} app registrations") return app_registrations @@ -243,6 +238,12 @@ def send_notifications(app_registrations): # Generate HTML content html_content = generate_html(app_registrations) + # Export JSON and HTML files + with open('debug_app_registrations.json', 'w') as f: + json.dump(app_registrations, f, indent=2) + with open('app_registrations.html', 'w') as f: + f.write(html_content) + # Create email message subject = "App Registration Expiry Notification" msg = MIMEText(html_content, 'html')