How to query for the list of members and their basic profiles, including Teams user IDs?

别来无恙 提交于 2020-04-17 22:50:56

问题


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

  1. Step 1: Request an access token from the Azure AD v2 account login service
  2. Step 2: Obtain TenantID
  3. Step 3: Get User Access Token https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

  4. Step 4: Call My Joined Team, get ID https://graph.microsoft.com/v1.0/me/joinedTeams

  5. Step 5: Findchannels of a team https://graph.microsoft.com/v1.0/teams/{{TeamId}}/channels
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!