I logged into Azure Portal using my outlook user account and registered a new app, created a user-specific (not tenant specific) token and successfully accessed the mail list through outlook api. I want to do the same using tenant. So, I created a new Azure Active Directory Domain (mydomain.onmicrosoft.com for example) and added few users to it. I created a tenant-specific token and tried to access the following:
https://graph.microsoft.com/v1.0/users/username@mydomain.onmicrosoft.com/messages
but, I got the error below.
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "576e0c7b-dc27-4d3e-b58e-37ac15346b2f",
"date": "2019-12-02T10:14:44"
}
}
}
Is this because my - username@mydomain.onmicrosoft.com - does not have a mailbox? What should I do to get a mailbox for this custom domain? How do I access the list of mails for any user in my custom domain through outlook api? Please advise.
PS:
https://graph.microsoft.com/v1.0/users/username@mydomain.onmicrosoft.com
The above endpoint gives the user details correctly. However,
https://graph.microsoft.com/v1.0/users/username@mydomain.onmicrosoft.com/messages
does not return the mail list
Is this because my - username@mydomain.onmicrosoft.com - does not have a mailbox? What should I do to get a mailbox for this custom domain?
Yes, you are right. These users don't have a mailbox. You need an O365 subscription for your AAD, then you can assign the license to the users which you need a mailbox.
Reference:
Understand subscriptions and licenses in Office 365 for business