I'm trying to get the information of an outlook.com user mailbox and subsequently the detailed information of each message but I'm having problems with the generated Token. It's giving me a ResourceNotFound code when I try to get the message list. These are the steps that I've taken in order to generate the token.
1.- Microsoft Azure
I've registered a new application in Azure Active Directory. I've added the user that I want the info from as a Guest user, generated a Client Secret, added this URI (https://localhost/myapp/) as a Redirect URI and activated the Mail.Read permission (Both Delegated and Application) among others.
2.- Token Generation
Using the Ids from the application created the previous step I proceeded to generate a code using this URL in my browser and logging in to the Outlook account: https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/authorize?client_id={ClientId}&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%2Fmyapp%2F&scope=offline_access%20mail.read&response_mode=query&state=12345
Once I got the code, I made a POST request via Postman to https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token with a form-data body containing the required parameters according to the documentation, one of them being the code in question.
With that I'm able to succesfully generate an Access Token and a Refresh Token. Now, when I use this Token for a GET request to the endpoint https://graph.microsoft.com/v1.0/me/ I can retrieve the data of the account.
But when I use it for a request to the endpoint https://graph.microsoft.com/v1.0/me/messages I get the error code ResourceNotFound.
Is there something I'm missing? I'm following the documentation provided in this link: https://docs.microsoft.com/en-us/graph/auth-v2-user. Thanks in advance to everyone that can help.
{TenantId}
in your authorize URL withcommon
orconsumers
and see if that helps? This is assuming you set your app registration to allow users from any organization and personal accounts. – Jason Johnston