microsoftgraph/aspnet-connect-rest-sample

Unauthorized 401: Retrieving Inbox Mails using this project.

ShahVivek opened this issue · 2 comments

Using this sample code I am trying to retrieve my Inbox top 10 mail but I am getting the 401 Unauthorized error. I have added "Mail.Read" permission for Delegated Permissions and Application Permissions in registaration page and in web config I added "Mail.Read" in GraphScopes.
"Send Mail" and "Get Email Address" works fine with me , but not able to read Inbox mails.
Can anybody help me in this ?

Hi @ShahVivek . For this sample, you shouldn't need to specify permissions in the app registration portal. It just sends the scopes to the Azure AD v2.0 auth endpoint.

I was able to extend the sample to get messages. I added the GET https://graph.microsoft.com/v1.0/me/messages call and the Mail.Read permission to ida:GraphScopes in Web.config. My test users were redirected to the consent dialog again, which this time it included the new "Read your mail" permission. (This is how the Azure AD v2.0 auth endpoint is supposed to handle dynamic permissions.)

You might want to start from scratch and register a new app. If you still have problems, can you please inspect the token? You can put a breakpoint on line 58 in Helpers/SampleAuthProvider.cs to capture it. Then paste it into https://jwt.io and look at the scp value. It sounds like yours should have Mail.Send User.Read Mail.Read.

Hi @ShahVivek . Closing this issue. Please reopen if you're still having problems.