Forum Discussion
MS Purview InformationProtectionPolicy - Extract Sensitivity Labels - Permissions Granted
Hello community, I'm currently facing an issue trying to extract sensitivity labels from our Microsoft 365 tenant and could use some assistance.
I have already ensured that the necessary permissions and application are in place. I initially attempted to retrieve the labels via the Microsoft Graph Explorer (graph-explorer) using the endpoint:
https://graph.microsoft.com/beta/security/informationProtection/sensitivityLabels. As you can see in the attached image, I encountered a "Forbidden - 403" error, suggesting a problem with permissions or consent, even though InformationProtectionPolicy.Read is listed under the "Modify permissions" tab as "Unconsent".
The only way that I found to solve it was using "https://graph.microsoft.com/beta/me/security/informationProtection/sensitivityLabels" but I need to use it in Python Code, without a user validation of credential.
Next, I tried to achieve the same using Python and the Microsoft Graph API directly. I obtained an access token using a Client ID and Secret, authenticating against https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token. The application associated with this Client ID and Secret has been granted the InformationProtectionPolicy.Read permission. However, when making a GET request to https://graph.microsoft.com/beta/security/informationProtection/sensitivityLabels in Python, I receive the following error:
I have already granted what I believe are the relevant permissions, including InformationProtectionPolicy.Read.All, InformationProtectionPolicy.Read, Application.Read.All, and User.Read.
Has anyone successfully retrieved sensitivity labels using the Microsoft Graph API?
If so, could you please share any insights or potential solutions?
I'm wondering if there are other specific permissions required or if there's a particular nuance I might be missing. Any help would be greatly appreciated!
Thank you in advance.
Leonardo Canal
2 Replies
- milgo
Microsoft
Hello Leonardo!
For Application Permissions, InformationProtectionPolicy.Read.All is what is required to successfully call the endpoint. Please double check and ensure that the permissions is Admin Consented before retrying.
Please review the Microsoft Graph Permissions reference for this specific permission here