I have a registered application in Azure portal which helps in fetching emails from a mail address. The application has all API permissions related to mail set to read and write permissions. The steps I follow to fetch emails are:
- I call https://login.microsoft.com/{org-id}/oauth2/v2.0/token with the application client id and client secret to get the refresh token & access token
- I use the above tokens to invoke graph API https://graph.microsoft.com/v1.0/me/messages along with filter parameters to fetch emails.
All these above actions are done through a backend service running on NodeJS, and whenever we sent email to that particular mail address (say, email address removed for privacy reasons), the backend service invokes above APIs to return emails from email address removed for privacy reasons.
Now, I have another shared mailbox (say, email address removed for privacy reasons) and I want to use the application to fetch emails from that inbox as well. I already had done few workarounds, but none has worked.
- I changed the URL to https://graph.microsoft.com/v1.0/users/{id | shared mailbox address}/messages but I keep getting Access denied error.
- I have already given all Shared consent API permissions of the application.
Appreciate any help.