403 Client ErrorForbidden URL

Biju Mathew 476 Reputation points

Hello team,

I am facing an interesting problem.

I am looking to get the list of sensitivity labels defined in Purview.

I am following the advice here, https://learn.microsoft.com/en-us/answers/questions/1394341/how-to-get-the-list-of-sensitivity-label-names

For testing, I am using Postman to get the access token and then invoke the Graph API. It works fine.

Now, when i automate the code in a Python notebook in Fabric, I run into this error:

403 Client Error: Forbidden for url: https://graph.microsoft.com/beta/security/informationProtection/sensitivityLabels

I am not able to understand why it works in Postman but not in Python code.

In the python code, I am using the Requests library. I first get the access token and then invoke the graph API.

I thought the access token may not have been received correctly in the Python code, but i can see it being there.

To test if the token is right, I used this token from the Python code and tested in PostMan, it works! so not sure why Python code is throwing up the 403 client error forbidden.

Any tips to resolve this please,

Azure Information Protection
Azure Information Protection
An Azure service that is used to control and help secure email, documents, and sensitive data that are shared outside the company.
523 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,040 questions
{count} votes