2
votes

First post...here goes. I am trying to display email from a shared mailbox but run into "ErrorAccessDenied Access is denied. Check credentials and try again".

The user does have permission to the mailbox, I can access/read email in Outlook and in O365 portal. In my app I have also assigned Mail.Read.Shared and Mail.ReadWrite.Shared scopes.

At first I tried Graph Explorer

https://graph.microsoft.com/beta/users/<userPrincipalNameOfSharedMailbox>/messages

but same ErrorAccessDenied, assumed Graph Explorer did not have Mail.Read.Shared scope.

Next I tried to modify Microsoft Graph Snippets Sample for ASP.NET 4.6

I added Mail.Read.Shared and Mail.ReadWrite.Shared and was prompted to accept these permissions

• Read and write mail you can access

• Read mail you can access

but I get the same error when I try get mail from the shared mailbox

IUserMessagesCollectionPage messages = await graphClient.Users["userPrincipalNameOfSharedMailbox"].Messages.Request().GetAsync();

There was a similar post here Microsoft Graph API SDK .NET Issues getting other users emails and the answer implies this is possible. If it is can anyone provide some insight as to what I am missing? thanks

1

1 Answers

1
votes

Right now, accessing shared messages is not supported for the authorization_code flow, but it is supported for the client_credentials flow. In order to incorporate this functionality, you will have to change your flow to incorporate this.

Here is an article on creating a client_credentials flow app if you are interested in going this route.