How to restrict the set of users in an Azure directory for OAuth2.0 authentication token

Copper Contributor

We are trying to replace the basic authentication with Oauth2.0, and created a "workable" solution with below steps [1]:
1.register application (TestApp for example) in Azure AD with some application permissions: (Microsoft Graph) and full_access_as_app (Office 365 Exchange Online)
2.Grant admin consent for AD
3.Add code to get authentication token by using client credential provider

4.Add token to EWS request

The issue we found is every user under this Azure AD can fetch email from mailboxes with requested token by using TestAPP's data: client_id, client_secret, tenant_id.

Is there any way to restrict the set of users in this Azure AD to request the authentication token?
The "Enable User assignment required" method[2] didn't solve the issue as all users under Azure AD can fetch the emails with auth token acquired by using TestAPP's data.

Please let me know if anyone has any advices for this issue, thanks in advance!



0 Replies