Microsoft Graph API .NET无法读取共享邮件 [英] Microsoft Graph API .NET not able to read shared mail
问题描述
第一篇文章...来了.我试图显示来自共享邮箱的电子邮件,但遇到"ErrorAccessDenied访问被拒绝.请检查凭据,然后重试".
First post...here goes. I am trying to display email from a shared mailbox but run into "ErrorAccessDenied Access is denied. Check credentials and try again".
用户确实具有邮箱的权限,我可以在Outlook和O365门户中访问/阅读电子邮件.在我的应用程序中,我还分配了Mail.Read.Shared和Mail.ReadWrite.Shared范围.
The user does have permission to the mailbox, I can access/read email in Outlook and in O365 portal. In my app I have also assigned Mail.Read.Shared and Mail.ReadWrite.Shared scopes.
起初我尝试使用Graph Explorer
At first I tried Graph Explorer
https://graph.microsoft.com/beta/users/<userPrincipalNameOfSharedMailbox>/messages
但使用相同的ErrorAccessDenied,假设Graph Explorer没有Mail.Read.Shared范围.
but same ErrorAccessDenied, assumed Graph Explorer did not have Mail.Read.Shared scope.
接下来,我尝试修改用于ASP.NET 4.6的Microsoft图形片段示例
我添加了Mail.Read.Shared和Mail.ReadWrite.Shared,并被提示接受这些权限
I added Mail.Read.Shared and Mail.ReadWrite.Shared and was prompted to accept these permissions
•读写您可以访问的邮件
• Read and write mail you can access
•阅读您可以访问的邮件
• Read mail you can access
但是当我尝试从共享邮箱中获取邮件时,我得到了相同的错误
but I get the same error when I try get mail from the shared mailbox
IUserMessagesCollectionPage messages = await graphClient.Users["userPrincipalNameOfSharedMailbox"].Messages.Request().GetAsync();
这里有一个类似的帖子 Microsoft Graph API SDK .NET问题使其他用户收到电子邮件,而答案表明这是可能的.如果是的话,谁能提供我所缺少的见识?谢谢
There was a similar post here Microsoft Graph API SDK .NET Issues getting other users emails and the answer implies this is possible. If it is can anyone provide some insight as to what I am missing? thanks
推荐答案
目前,authorization_code流不支持访问共享消息,但client_credentials流不支持 .为了合并此功能,您将必须更改流程以合并此功能.
Right now, accessing shared messages is not supported for the authorization_code flow, but it is supported for the client_credentials flow. In order to incorporate this functionality, you will have to change your flow to incorporate this.
Here is an article on creating a client_credentials flow app if you are interested in going this route.
这篇关于Microsoft Graph API .NET无法读取共享邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!