anonymous user Ideally, you should have consented to the directory.read.all permission on behalf of your app which should give you the application required consent. Can you confirm the same?
We strongly recommend using Microsoft Graph API for accessing resources from Azure AD. Azure AD Graph calls will be deprecated in the near future.
Ref: https://video2.skills-academy.com/en-us/graph/api/signin-get?view=graph-rest-1.0&tabs=http
https://developer.microsoft.com/en-us/office/blogs/microsoft-graph-or-azure-ad-graph/