Azure Entra IDのエンタープライズアプリケーションを取得する

Application.Read.Allが必要。

cf. アプリケーションを取得する - Microsoft Graph v1.0 | Microsoft Learn

#!/usr/bin/env python
# pip install azure-identity msgraph-sdk
import asyncio
import pprint
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient

client_id = "..."
tenant_id = "..."
client_secret = "..."

credentials = ClientSecretCredential(
    tenant_id=tenant_id, client_id=client_id, client_secret=client_secret
)
scopes = ["https://graph.microsoft.com/.default"]
client = GraphServiceClient(credentials=credentials, scopes=scopes)


async def print_app():
    apps = await client.applications.get()
    for app in apps.value:
        pprint.pprint(app.display_name)


asyncio.run(print_app())