The objective : having a one time consent of an admin to be able to read all company mailboxes, using some functionalities of Graph API, and some of Outlook REST API (webhooks are more advanced)
Reading the Microsoft doc, it seems the best flow is "OAuth 2.0 client credentials grant".
- My app is created through apps.microsoft.com, scopes are defined to access all mailboxes.
- The admin connects to
https://login.microsoftonline.com/common/adminconsent?client_id=XXX&redirect_uri=XXX
. Then I retrieve the token to
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
withgrant_type=client_credentials&client_id=XX&client_secret=XX&scope=https://graph.microsoft.com/.default
The token is returned. Everything works perfectly with Microsoft Graph.
But when I retrieve a token, changing the scope to https://outlook.office.com/.default
, I get a token which is refused for my query, with a 401 and a 'too weak token with strength 1 instead of 2'.
Where should we change the scopes ? Or should I have another authorization flow ?
Thanks