简体   繁体   English

尝试使用 Graph API 从 Web App 获取用户频道并将消息发布到 MS Teams 频道

[英]Trying to use Graph API to get user's channels and post messages to MS Teams Channel from Web App

I'm trying to write a web app on our website which gets a User's MS Team channels and then posts a message to a channel of their choosing using MS Teams Graph API.我正在尝试在我们的网站上编写一个 web 应用程序,该应用程序获取用户的 MS Team 频道,然后使用 MS Teams Graph API 将消息发布到他们选择的频道。

I'm about to get an access token using the OAuth API, and I'm passing access token (AAD token) to the /me/joinedTeams endpoint, it's giving me the below error:我即将使用 OAuth API 获取访问令牌,并且我将访问令牌(AAD 令牌)传递给 /me/joinedTeams 端点,它给了我以下错误:

{ "error": { "code": "ResourceNotFound", "message": "Resource not found.", "innerError": { "date": "2021-05-14T20:57:03", "request-id": "30d80d9a-66f4-47ff-ab11-dacb7f817806", "client-request-id": "30d80d9a-66f4-47ff-ab11-dacb7f817806" } } } { "error": { "code": "ResourceNotFound", "message": "Resource not found.", "innerError": { "date": "2021-05-14T20:57:03", "request-id" “:“30d80d9a-66f4-47ff-ab11-dacb7f817806”,“客户端请求-id”:“30d80d9a-66f4-47ff-ab11-dacb7f817806”}}}

Screenshot of my Graph Explorer results我的 Graph Explorer 结果的屏幕截图

UPDATE:更新:

I have gotten my account converted to a Work account, and added the permissions.我已将我的帐户转换为工作帐户,并添加了权限。 Now I am getting this response/error:现在我收到此响应/错误:

Screenshot of new Graph Explorer results新 Graph Explorer 结果的屏幕截图

It's better for you to share how to get an access token using the OAuth API.最好分享一下如何使用 OAuth API 获取访问令牌。 In this issue, it seems your signed-in user is a personal Microsoft account, that's not supported to access the /me/joinedTeams endpoint.在此问题中,您的登录用户似乎是个人 Microsoft 帐户,不支持访问/me/joinedTeams端点。 Doc of this API.API的文档。

在此处输入图像描述

There are some notes here:这里有一些注意事项:

  1. When using Graph Explorer, access token is here after login.使用 Graph Explorer 时,登录后访问令牌在此处。 You don't need to add bearer token in Request headers.您不需要在请求标头中添加不记名令牌。

在此处输入图像描述

  1. You have to sign in with a work or school account, and you need to consent one of the required permissions in "modify permissions(Preview)".您必须使用工作或学校帐户登录,并且您需要同意“修改权限(预览)”中所需的权限之一。

在此处输入图像描述

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

相关问题 MS Graph 团队 api 无法将消息发布到频道并获取频道的消息 - MS Graph teams api cann't post message to channel and get channel's messages 如何使用 MS Graph 获取 Microsoft Teams 中的频道列表? - How to get a list of channels in Microsoft Teams using MS Graph? 如何从MS Graph API获取用户的基本详细信息 - How to get user's basic details from MS Graph API Microsoft Teams,使用 MS Graph API 获取所有聊天消息 - Microsoft Teams, Fetch ALL chat messages with MS Graph API 使用 MS Graph API 从 Python 桌面应用程序调用(MS Teams)给另一个人 - Use MS Graph API to call (MS Teams) to another person from Python Desktop Application 使用 MS Graph API 获取我的用户信息 - Get my user's information using MS Graph API 如何将频道添加到 MS 团队中的自定义应用程序? - How can I get the channels added to my custom app in MS teams? 代表当前登录单独Web客户端的用户从API访问MS Graph - Accessing MS Graph from API on behalf of user currently signed in to separate web client 是否可以使用MS Graph REST API在代码中登录用户并获取身份验证令牌? - Is it possible to use MS Graph REST API to login a user in code and get an auth token? 使用 dot Net MS Graph SDK 获取自己的用户信息时出现错误代码 406? - Error code 406 when I use dot Net MS Graph SDK to get myself's user info?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM