question

ShivaniMandeliya-8731 avatar image
0 Votes"
ShivaniMandeliya-8731 asked Deva-MSFT answered

Fetching Email content with Microsoft graph API using admin credentials

I am trying to retrieve the outlook messages of an user using the following API end point -

https://graph.microsoft.com/v1.0/users/{userPrincipalName}/messages

However, it is not working at all. I am the admin and hence using my own credentials (instead of using an app)
It works fine if I want to see my own data with this call - https://graph.microsoft.com/v1.0/users/me/messages



microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered

You need to do the following:

  • Some apps call Microsoft Graph with their own identity and not on behalf of a user (say, Client Credential flow). For this you need to start with setting authentication/authorization steps as described here[https://docs.microsoft.com/en-us/graph/auth-v2-service#authentication-and-authorization-steps] and the detailed steps.

  • Configure the permissions for Microsoft Graph

  • Get admin consent, get access token and use it to call Graph

  • Now you can access the other user mailbox and its items.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.