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:
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 @mnayar 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.
No, these are the only keys I have listed when I run it in Postman
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.
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.
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.
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.
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?
Check out the News & Announcements to learn more.
Microsoft received the highest score of any vendor in both the strategy and current offering categories.
Mark your calendars and join us for our next Power BI Dev Camp!
Check out our new Discover Your Career Path blog post series and get all the details.