Using python, and having an azure applicationID/ objectID/ tenantID / clientID and clientSecret I want to access a "teams" meeting using e.g. requests
to get the list of participants of an ongoing teams meeting. Having searched with google and using chatgtp, there seems to be a lot of confusion between existing and non-exsting modules like msgraph
,
msgraph-sdk
and msgraph-sdk-python
. They all do not seem to work, or they work differently.
I appreciate a small code python snippet that actually works, and that I can use to get the list of participants of an ongoing Teams call.
I had a code like the following which does not work:
from microsoftgraph.client import Client
client = Client(client_id, client_secret, account_type='common')
# Make a GET request to obtain the list of participants
call_id = '123 456 789'
response = client.get(f'/communications/calls/{call_id}/participants', headers={'Authorization': f'Bearer {access_token}'})
participants = response.json()
Error:
AttributeError: 'Client' object has no attribute 'get'
I also found this quick start guide in which I unfortunately have to request access, and I will not know if someone ever will reply to my request.
2
Answers
You can use below python code to get the list of participants of a teams call:
I registered one Azure AD application and granted
API permissions
as below:Initially, I ran below code to get details regarding the call like this:
Response:
Similarly, you can run below python code to get the list of participants of a teams call:
Response:
To access Microsoft Teams API and retrieve the list of participants in an ongoing Teams call, you can use the
requests
library along with the Microsoft Graph API. Here’s a small Python code snippet that demonstrates how to achieve this:Make sure to replace ‘YOUR_CLIENT_ID’, ‘YOUR_CLIENT_SECRET’, ‘YOUR_TENANT_ID’, and ‘YOUR_CALL_ID’ with your actual Azure AD credentials and the ID of the Teams call you want to retrieve the participants for.
This code snippet uses the requests library to send HTTP requests to the Microsoft Graph API. It first obtains an access token using your Azure AD credentials. Then, it makes a GET request to the Teams API endpoint to fetch the participants of the specified call. Finally, it processes the response JSON to extract and print the display names of the participants.
Please note that you may need to install the requests library if you don’t have it already. You can install it using pip install requests.