A cloud-based identity and access management service for securing user authentication and resource access
How to request email silently in a loop?
Hen Golden
20
Reputation points
Sridevi Machavarapu , I am currently running the following loop to continuously fetch the incoming mail list:
while True:
result = await graph_client.me.messages.get(request_configuration=request_configuration)
messages_list = []
if hasattr(result, "value"):
for msg in result.value:
msg_dict = {
"id": msg.id,
"subject": msg.subject,
"from": msg.from_.email_address.address if msg.from_ else None,
"bodyPreview": msg.body_preview,
"receivedDateTime": str(msg.received_date_time)
}
messages_list.append(msg_dict)
print(json.dumps(messages_list, indent=4))
await asyncio.sleep(1)
Although the app only ask for authentication in a pop-up window for the first iteration, I wonder if the authentication will expire and need to be manually re-authenticate? and in that case, how could I implement this such that it can proceed silently, without the need to intervene?
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Sign in to answer