Sameer
Sameer

Reputation: 11

Accessing all user's mailbox via Office 365 REST API

I am trying out Office 365 Rest APIs.

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.

Upvotes: 1

Views: 4266

Answers (2)

Fedeco
Fedeco

Reputation: 876

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.

Upvotes: 1

Venkat Ayyadevara - MSFT
Venkat Ayyadevara - MSFT

Reputation: 2883

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.

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.

Upvotes: 1

Related Questions