I am trying to read emails of users in a tenant. The admin has granted consent for the following permissions:
offline_access AccessReview.Read.All AccessReview.ReadWrite.All APIConnectors.ReadWrite.All Channel.ReadBasic.All ChannelMessage.Read.All ChannelSettings.Read.All Chat.Read ChatMessage.Read DelegatedPermissionGrant.ReadWrite.All Directory.Read.All Directory.ReadWrite.All Mail.Read Mail.Read.Shared Mail.ReadBasic Mail.ReadWrite MailboxSettings.Read openid profile TeamMember.Read.All TeamSettings.Read.All User.Read User.Read.All User.ReadBasic.All email
I can read the emails of the admin (the signed in user) but not other users in the tenant.
https://graph.microsoft.com/v1.0/users/<email_of_signed_in_user>/messages
works but https://graph.microsoft.com/v1.0/users/<email_of_any_other_user_in_the_tenant>/messages
does not work but instead I get the below error:
"error": {
"code": "ErrorItemNotFound",
"message": "The specified object was not found in the store., Default folder AllItems not found.",
"innerError": {
"date": "2022-11-29T09:16:49",
"request-id": "2449c64a-9aa8-479d-8de4-923a2a306583",
"client-request-id": "5eb26a2e-54da-bba2-0adf-4fa7bca43df2"
}
}
What could be the issue? How do I read emails of users in a tenant with Oauth token? The admin has already granted the permissions in Azure AD.