如何查询成员列表及其基本资料,包括 Teams 用户 ID?

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

是否提供端到端示例来查询成员列表及其基本配置文件,包括 Teams 用户 ID 和 Azure Active Directory (Azure AD)?

我正在关注 https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json 和 microsoft graph Postman 合集,但它似乎太复杂了,我无法理解。

我需要为我的 MS 团队获取所有用户 ID

您关注的 document 确实是用来获取您需要的信息,包括 Teams 用户 ID 和 Azure Active Directory (Azure AD)。

不知道你哪里不太明白。但强烈建议先了解Bot Framework Rest API reference.

你应该注意如何获得Base URIserviceUrl)。之后,您可以在 /conversations/{teamId}/members/ 上发出 GET 请求,使用的值作为端点:serviceUrl.

像这样:

GET https://{serviceUrl}/v3/conversations/{teamId}/members/
Authorization: Bearer {access token}
Content-Type: application/json

有关如何为您的机器人获取访问令牌的详细信息,请参阅 Authenticate requests from your bot to the Bot Connector service

现在您有了请求端点和 headers。您可以在 Postman 中测试 Rest API。

获取团队用户详细信息的最佳方式是 fetching roster details

您也可以使用图表 API 来获得 members of a team/group。但这 API 提供了用户的基本详细信息。喜欢

[
    {
        "@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"
    },
]

以下是我用来获取团队用户 ID 的命令

  1. 第 1 步:从 Azure AD v2 帐户登录请求访问令牌 服务
  2. 第 2 步:获取 TenantID
  3. 第 3 步:获取用户访问令牌 https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/令牌

  4. 第 4 步:致电我加入的团队,获取 ID https://graph.microsoft.com/v1.0/me/joinedTeams

  5. 第五步:寻找团队渠道 https://graph.microsoft.com/v1.0/teams/{{TeamId}}/频道
  6. 第 6 步: 使用以下方法查找所有用户配置文件 https://{{serviceUrl}}/v3/conversations/{{channelid}}/members/