简体   繁体   English

Microsoft Teams Graph API 在未经管理员同意的情况下获取用户所属的团队?

[英]Microsoft Teams Graph API get teams a user is a member of without admin consent?

I want to get a list of teams for a given user without needing admin_consent .我想在不需要admin_consent的情况下获取给定用户的团队列表。 Is this possible?这可能吗? I assumed that if a user consents to an application and I get an access token for them that I would be able to request information scoped to that single user, like what teams they are a part of.我假设如果用户同意应用程序并且我为他们获得了访问令牌,我将能够请求仅限于该单个用户的信息,例如他们所属的团队。

But after looking at the api permissions /me/joinedTeams it looks like admin_consent is needed for all of them, which is problematic.但是在查看 api 权限/me/joinedTeams之后,似乎所有这些权限都需要admin_consent ,这是有问题的。

Turns out due to some API weirdness you can use /me/memberOf without admin_consent to at least get the ID's of all teams the user has permissions to.事实证明,由于某些 API 怪异,您可以在没有admin_consent的情况下使用/me/memberOf来至少获取用户有权访问的所有团队的 ID。

/me/joinedTeams however will just return a 403 Forbidden . /me/joinedTeams但是只会返回403 Forbidden

Also if you want to map the "external"?另外,如果你想 map “外部”? id for a team returned from /me/memberOf to the "internal" id that a Teams message will have (begins with 19: ) you can still use the /teams/{id} endpoint also without any admin credentials to get just the internal ID for the team./me/memberOf返回到 Teams 消息将具有的“内部”id 的团队的 id(以19:开头)您仍然可以使用/teams/{id}端点,也无需任何管理员凭据来获取内部团队的 ID。

To get the the teams the user is a member of is possible from application as well也可以从应用程序中获取用户所属的团队

URL-> https://graph.microsoft.com/v1.0/users/{{UserId}}/joinedTeams URL-> https://graph.microsoft.com/v1.0/users/{{UserId}}/joinedTeams

Authorization -> BEARER {{AppAccessToken}}授权 -> BEARER {{AppAccessToken}}

To get the app access token获取应用访问令牌

URL -> https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token URL -> https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

Body-> x-www-urlform-encoded正文-> x-www-urlform-encoded

grant_type-> client_credentials grant_type-> client_credentials

client_id -> {{ClientID}} client_id -> {{ClientID}}

client_secret -> {{ClientSecret}} client_secret -> {{ClientSecret}}

scope -> https://graph.microsoft.com/.default scope -> https://graph.microsoft.com/.default

you will need you app to have permission你需要你的应用程序获得许可

1- > teams.setting.user.all 1-> 团队.setting.user.all

2 -> teams.read.basic.all 2->teams.read.basic.all

see if some other permissions are also required But this worked for me.看看是否还需要其他一些权限但这对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 Microsoft Graph API 的 Microsoft Teams 中的 @Mention 用户不会标记用户。 我错过了什么? - @Mention user in Microsoft Teams with Microsoft Graph API does not tag the user. What am I missing? 在微软团队中发送用户通知 - Sending user notifications in microsoft teams Microsoft Graph - 创建团队 API 返回“容器导航属性不支持绑定请求。” - Microsoft Graph - Create Teams API Returns "Bind requests not supported for containment navigation property ." 如何使用 PowerShell Azure 函数和 Graph API 创建 Microsoft Teams 团队? - How to create a Microsoft Teams team using a PowerShell Azure function and the Graph API? 如何通过 REST API 在传入 Webhook 消息中提及 Microsoft 团队频道中的用户/频道? - how to mention user/channel in microsoft teams channel in an Incoming Webhook message through REST API? Microsoft Teams - 如何使用 MS Graph 在 Teams 频道中检索有关未读消息的信息 - Microsoft Teams - How to retrieve information about unread messages in a Teams Channel with MS Graph 微软团队:REST API - Microsoft Teams : REST APIs 如何从外部 api 向 Microsoft Teams(跨多个团队)中的特定用户发送通知 - How to send notifications to specific users in Microsoft Teams (across multiple teams) from an external api SugarCRM REST API如何获取模块团队列表 - SugarCRM REST API how to get the list of teams of the module 将带有换行符的文件列表输出到Microsoft Teams - Outputting file list with linebreaks to Microsoft Teams
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM