aio fix
This commit is contained in:
17
aio.py
17
aio.py
@@ -1,13 +1,13 @@
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import msal
|
|
||||||
import requests
|
|
||||||
import smtplib
|
import smtplib
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import formataddr
|
from email.utils import formataddr
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import requests
|
||||||
|
import msal
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@@ -47,7 +47,6 @@ def get_app_registrations():
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# Fetch app registrations with owners
|
# Fetch app registrations with owners
|
||||||
# Updated URL to include both app registration and owner data
|
|
||||||
graph_url = (
|
graph_url = (
|
||||||
"https://graph.microsoft.com/v1.0/applications"
|
"https://graph.microsoft.com/v1.0/applications"
|
||||||
"?$select=id,appId,displayName,passwordCredentials"
|
"?$select=id,appId,displayName,passwordCredentials"
|
||||||
@@ -63,10 +62,6 @@ def get_app_registrations():
|
|||||||
response = requests.get(graph_url, headers=headers)
|
response = requests.get(graph_url, headers=headers)
|
||||||
response.raise_for_status()
|
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', [])
|
app_registrations = response.json().get('value', [])
|
||||||
logging.info(f"Fetched {len(app_registrations)} app registrations")
|
logging.info(f"Fetched {len(app_registrations)} app registrations")
|
||||||
return app_registrations
|
return app_registrations
|
||||||
@@ -243,6 +238,12 @@ def send_notifications(app_registrations):
|
|||||||
# Generate HTML content
|
# Generate HTML content
|
||||||
html_content = generate_html(app_registrations)
|
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
|
# Create email message
|
||||||
subject = "App Registration Expiry Notification"
|
subject = "App Registration Expiry Notification"
|
||||||
msg = MIMEText(html_content, 'html')
|
msg = MIMEText(html_content, 'html')
|
||||||
|
|||||||
Reference in New Issue
Block a user