问题
Is there an end-to-end sample provided to query for the list of members and their basic profiles, including Teams user IDs and Azure Active Directory (Azure AD)?
I am following https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json and microsoft graph Postman collection, however it seems too complex for me to understand.
I need to fetch all the userId under for my MS Team
回答1:
The document you are following is indeed used to get the information you need, including Teams user IDs and Azure Active Directory (Azure AD).
I'm not sure where you don't quite understand. But it's strongly suggested to firstly learn about Bot Framework Rest API reference.
You should pay attention to how to get the Base URI (serviceUrl
). After that, you could issue a GET request on /conversations/{teamId}/members/
, using the value of as the endpoint: serviceUrl
.
Like this:
GET https://{serviceUrl}/v3/conversations/{teamId}/members/
Authorization: Bearer {access token}
Content-Type: application/json
For details about how to obtain an access token for your bot, see Authenticate requests from your bot to the Bot Connector service.
Now you have the request endpoint and headers. You could test the Rest API in Postman.
回答2:
The best way to get teams user details is by fetching roster details.
You can also use Graph API for getting members of a team/group. But this API provides basic details of user. like
[
{
"@odata.type": "#microsoft.graph.user",
"id": "xxxxxxx-95ea-xxxxxxxxx",
"businessPhones": [
"xxxxxxxxxxxxx"
],
"displayName": "Vivek",
"givenName": "Vivek",
"jobTitle": "xxxxxxxx",
"mail": "xxxxxxxx@microsoft.com",
"mobilePhone": "xxxxxxxxxxx",
"officeLocation": "LINCOLN xxxxxxxxx",
"preferredLanguage": null,
"surname": "Shah",
"userPrincipalName": "xxxxxxxx@microsoft.com"
},
]
回答3:
Below are the commands I used to fetch Team user IDs
- Step 1: Request an access token from the Azure AD v2 account login service
- Step 2: Obtain TenantID
Step 3: Get User Access Token https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token
Step 4: Call My Joined Team, get ID https://graph.microsoft.com/v1.0/me/joinedTeams
- Step 5: Findchannels of a team https://graph.microsoft.com/v1.0/teams/{{TeamId}}/channels
- Step 6: Find all the user profile using following https://{{serviceUrl}}/v3/conversations/{{channelid}}/members/
来源:https://stackoverflow.com/questions/60550732/how-to-query-for-the-list-of-members-and-their-basic-profiles-including-teams-u