Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, I am trying to get an authroization token from Azure Service Principal using Postman and Power Query so I can query the Power BI Rest API but I keep getting an error. I cannot use a username and password to pull the data so we have set up a code and clientsecret. Has anyone had any experience setting it up? I have tried the configuration in POSTMAN and Power Quer
The URL I am using is: https://login.microsoftonline.com/<tenantid>/oauth2/authorize
Other parameters included in the body:
client_id
code
client_secret
grant_type: authorization_code
response_mode: query
resource: https://analysis.windows.net/powerbi/api
I have also tried the following url https://login.microsoftonline.com/<tenantid>/oauth2/token
and I get an invalid_grant error
Other values set in the App Registeration are:
I am using the following code in Power Query
Hey @Anonymous I haven't setup using authorization_code grant types before, but I have used client_secrets. Have you tried changing your grant_type to client_credentials? Try changing your grant type on https://login.microsoftonline.com/<tenantid>/oauth2/token
see if that works for you.
If that doesn't work for you take a look at this info
You see towards the middle of the page how to use authorization_code grant types but it appears to have different keys than you're currently using.
Proud to be a Super User!
Hello Watsky, When you mentioned grant_type client_credentials does that require username and password?
No, these are the only keys I have listed when I run it in Postman
Proud to be a Super User!
Can you provide screenshot of the values you use for the above attributed?
Sure at least everything but my client_id and secret. Also, I'm on GCC so my resource is a bit different, so no need copying that over.
Proud to be a Super User!
So I was able to get an authorization code, but when I use it in within Power BI, it expects me to sign in, that shouldnt be requirement right?
It shouldn't be I just tested and I have my credentials set to Anoynmous.
Proud to be a Super User!
Could you share your Power Query Code for getting token and using that token in the call to get workspaces just so that I can confirm I got everything in there? Also, can you confirm the settings in Azure I have made?
as for your Azure settings. Has an admin granted privledges for the permissions? Looking at mine I have a granted/not granted by all of the permissions.
Proud to be a Super User!
Everything above is the same. I get an unauthozed 401 message in Postman when I use the authorization code generated in Power BI. My guess is there is something different in Azure config.
Hi @Anonymous.
I'd like to suggest you check if you used the same account on the power bi side which assigned the api permissions on the Azure side.
For this scenario, you can also contact azure support to trace the requests to get further information and support for troubleshooting.
BTW, it seems like you are work with admin API, have you assign the power bi admin permission on the test account?
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
2 | |
2 | |
1 | |
1 |