File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` py
2+ import asyncio
3+
4+ from azure.identity import EnvironmentCredential
5+ from kiota_abstractions.api_error import APIError
6+ from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
7+ from msgraph import GraphRequestAdapter
8+ from msgraph import GraphServiceClient
9+
10+ # Set the event loop policy for Windows
11+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
12+
13+ # Create authentication provider object. Used to authenticate request
14+ credential= EnvironmentCredential()
15+ auth_provider = AzureIdentityAuthenticationProvider(credential)
16+
17+ # Initialize a request adapter. Handles the HTTP concerns.
18+ request_adapter = GraphRequestAdapter(auth_provider)
19+
20+ # Get a service client.
21+ client = GraphServiceClient(request_adapter)
22+
23+ # GET ALL APPLICATIONS IN THE TENANT
24+ # Request: GET /applications
25+
26+ async def get_applications ():
27+ try :
28+ apps = await client.applications.get()
29+ if apps and apps.value:
30+ for app in apps.value:
31+ print (app.id)
32+ except APIError as e:
33+ print (e.error.message)
34+ asyncio.run(get_applications())
35+ ```
You can’t perform that action at this time.
0 commit comments