This was the problem: in the Azure function I was requesting the token againstthis endpoint: https://login.microsoftonline.com/{{tenant_id}}/oauth2/token Meanwhile in Postman I was using: https://login.microsoftonline.com/{{tenant_id}}/oauth2/v2.0/token which actually works.
Access token works in Postman but not in Azure Function
Luigi Marangio
45
Reputation points
Hello community, I need your help to understand better what is going on here.
Situation - desired result I developed, in python, an Azure function that:
- is triggered by a POST request
- use the package "requests" to get an access token (for service principal) for the PowerBI REST API use this access token to send a Post request to PowerBI
Postman If I run the exact same requests in Postman, I am able to
- retrieve the access token
- use this access token to send my POST request Everything works fine.
Azure Function
- the token is retrieved correctly
- the POST request to the PowerBI API fails with a 403
- If I copy and paste the access token retrieved by the script, and I used it in Postman, I also obtain a 403
- If I retrieve an access token with Postman, and I use it in the script, everything works fine.
Run/test section of the Azure function show me the following:
Looks like I haven't configured properly the network access of my azure function. Is there someone with experience in this field that can troubleshoot this error and explain what is going on? I did not set up the network infrastructure, so please, be as clear as possible:) Thanks! Luigi
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,932 questions