How to Fix Microsoft Defender for Cloud Apps API Token Admin Approval Error
Question details
The user's Python application fails to obtain an MSAL access token for the Microsoft Defender for Cloud Apps API due to an administrator approval requirement.

- Product
- Microsoft Defender for Cloud Apps, Microsoft Entra ID
- Device & OS
- not provided
- Scenario
- Authenticating a Python application using MSAL to access the Defender for Cloud Apps API.
- Observed behavior
- The sign-in response returns an error stating that administrator approval is required, even though the necessary API permissions were added to the app registration.
Ensure you have Global Administrator or Privileged Role Administrator rights in your Microsoft Entra ID (formerly Azure AD) tenant to grant the necessary consent.
Grant Tenant-Wide Admin Consent in Microsoft Entra ID
Resolve the admin approval error by having a tenant administrator grant tenant-wide consent for the requested API permissions.
Many high-privilege APIs, including Microsoft Defender for Cloud Apps, require administrative consent before an application can request access tokens. This prevents unauthorized applications from accessing sensitive organizational data.
Log in to the Microsoft Entra admin center (or Azure portal) using an account with administrator credentials.
Go to 'Identity', then select 'Applications', and click on 'App registrations'. Find and select your registered Python application.
Click on 'API permissions' from the left-hand menu to view the currently configured permissions for your application.
Click the 'Grant admin consent for [Your Tenant Name]' button located above the permissions list, and confirm the action when prompted.

Verify MSAL Application Credentials and Scopes
Ensure that your Python MSAL configuration matches the consented permissions and uses the correct OAuth scopes.
Boost Your Productivity with WPS Office
While configuring API permissions and managing tenant consent in Microsoft Entra ID requires specific admin tools, your daily documentation doesn't have to be complicated. WPS Office provides a lightweight, comprehensive suite for all your document, spreadsheet, and presentation needs without the complex configurations.

Frequently Asked Questions
Why does my MSAL Python app require admin approval?
In Microsoft Entra ID, certain high-privilege APIs, including Microsoft Defender for Cloud Apps, require an administrator to review and consent to the permissions before the application can request tokens on behalf of users or the tenant.
Who can grant admin consent in Microsoft Entra ID?
Only users with specific administrative roles, such as Global Administrator, Privileged Role Administrator, or Cloud Application Administrator, have the authority to grant tenant-wide admin consent for application permissions.
What should I do if the 'Grant admin consent' button is grayed out?
If the button is grayed out, it typically means your current account lacks the necessary administrative permissions in the Entra ID tenant. Contact your organization's IT admin to grant consent on your behalf.
Where can I find further support for Microsoft Defender for Cloud Apps API issues?
For specialized developer and API integration issues, it is recommended to consult the Microsoft Defender for Cloud Apps Q&A community or the MSAL for Python GitHub issue tracker for expert assistance.




