[英]Accessing all user's mailbox via Office 365 REST API
I am trying out Office 365 Rest APIs.我正在试用 Office 365 Rest API。
Sent following request ' https://outlook.office365.com/api/users/ {another user's email}/messages'.发送了以下请求“ https://outlook.office365.com/api/users/ {另一个用户的电子邮件}/messages”。 This resulted in following error
这导致了以下错误
"u'error': {u'message': u'Access is denied. Check credentials and try again.', u'code': u'ErrorAccessDenied'}}" "u'error': {u'message': u'Access is denied. Check credentials and try again.', u'code': u'ErrorAccessDenied'}}"
Please let me know if above steps are wrong?如果以上步骤有误,请告诉我?
If they are wrong, is there a way to fetch emails from another user's mailbox as I have admin credentials?如果他们错了,有没有办法从另一个用户的邮箱中获取电子邮件,因为我有管理员凭据?
Thanks.谢谢。
You need to use a service account as described in this blog , for your scenario and the app will be able to make calls to interact with any mailboxes in that tenant. 您需要使用此博客中所述的服务帐户,然后才能使用该应用程序,该应用程序才能拨打电话以与该租户中的任何邮箱进行交互。 The reason your request to use another user's mailbox is failing is because the request will be approved only if the app and user have permissions to access the other user's mailbox.
您使用其他用户的邮箱的请求失败的原因是,仅当应用程序和用户有权访问其他用户的邮箱时,该请求才会被批准。 In your case, the admin has permissions to the other user's mailbox.
在您的情况下,管理员有权访问另一个用户的邮箱。 But the app, assuming you used OAuth code flow, to get the OAuth token, only has permissions to the authenticated user's mailbox.
但是,假设您使用OAuth代码流来获取OAuth令牌,该应用仅具有对经过身份验证的用户邮箱的权限。
Also, you don't need "Access All User's Mailbox" permissions for REST APIs, as they are meant for using Exchange Web Services (EWS) SOAP APIs. 另外,您不需要REST API的“访问所有用户的邮箱”权限,因为它们用于使用Exchange Web服务(EWS)SOAP API。
If someone is looking for the solution, it was a problem of service principal.如果有人正在寻找解决方案,那是服务主体的问题。 We were pointing to the wrong Service Principal and that was the cause of the issues with permissions.
我们指向了错误的服务主体,这就是权限问题的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.