Forum Discussion
Power BI API with service principal - 401 unauthorized
Try getting the token with your resource set as:
https://analysis.windows.net/powerbi/api/.default
Also make sure that your tenant admin has added the AAD security group to the "specific security group" list in Power BI.
- matoxin5 years agoFrequent Visitor
When I tried getting the token with the resource set to https://analysis.windows.net/powerbi/api/.default, it threw the following error:
The AAD security group (and also the service principal) has been added to the specific security group list in our Power BI workspace.
- DavidCousinsT5 years agoAdvocate I
Oh, that's easy then. Your POST is wrong. Didnt spot it the first time round because it was right at the top 😄 It must have the tenant ID in it, not 'common'
I use:
https://login.microsoftonline.com/[tenantid]/oauth2/v2.0/token/
- DavidCousinsT5 years agoAdvocate I
Ah, you've been using a different API. Not sure that one would ever work. Heres the working oauth one I have:
- matoxin5 years agoFrequent Visitor
Thank you so much, this actually worked, I was finally able to generate a bearer token without any error messages.
The issue now is that whatever call I make using this token, I get the following error:
I tried finding more information about this and everything points to some issue with permissions, but I cannot figure out what's wrong (I have tested both non-admin and some of the supported admin calls). Please, do you have any idea what might be the problem?
UPDATE: some non-admin calls actually work, but I was not able to make any of the admin ones work properly. I have checked Azure again to make sure I have all the correct permissions assigned, and it seems to be the case:
Is anything missing?
- q2bi2 years agoFrequent Visitor
A long time has passed, do you remember how to add AD security group to PowerBI?