Hello. I'm working on a short shell script to remove e-mails from three different inboxes. Our M365 admin successfully registered, configured and authorized an app which allows us to get an access token via script.
We can read e-mails successfully from all three accounts but cannot delete e-mails. The admin has confirmed that the API does have the Mail.ReadWrite permission as mentioned here. When I test this out on my own account using my own token it works fine. Is there another permission needed in order to do this? Thank you.
curl -X DELETE -H "Authorization: Bearer $AccessToken" "https://graph.microsoft.com/v1.0/me/messages/$EmailID"