Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hey Guys,
i try to generate a bearer token i order to get data from admin api. I am able to generate a token but it is only working in normal api calls not on admin calls.
Steps i have done:
This works:
let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg",
[
RelativePath = "/groups" ,
Headers=[Authorization=
"Bearer " & #"GET AccessToken (3)"()]
]))
in
Source
this doesn't work:
let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg",
[
RelativePath = "/admin/groups?%24top=1000" ,
Headers=[Authorization=
"Bearer " & #"GET AccessToken (3)"()]
]))
in
Source
Error:
When i use token that is generated by learn page from ms. The token is much longer and works also for admin api calls.
the token is generated by this function:
() as text =>
let
tentant_id ="my tenant",
client_id = "my client",
client_secret = "my client secret",
appIDURL = "my api url",
url = "https://login.microsoftonline.com/"&tentant_id&"/oauth2/token",
body = " grant_type=client_credentials&
resource=https://analysis.windows.net/powerbi/api&
client_id="&client_id&"&
client_secret="&client_secret,
Data=Json.Document(
Web.Contents("https://login.microsoftonline.com/"&tentant_id&"/oauth2/token/",
[ Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(body)
])),
access_token = Data[access_token]
in
access_token
does anyone knows where my fault is?
I searched many threads but doesn't found any solution.
regards Benedikt
Hi, @Benedikt_Sch
Make sure the Azure AD application registration includes permissions specifically for the Power BI Admin API. This usually means having Tenant.Read.All or Tenant.ReadWrite.All permissions within the Power BI service permissions set. These permissions require admin consent (which you've mentioned you've already done, but it's worth double-checking).
Admin consent needs to be given at the tenant level. Sometimes, even if permissions appear to be correctly set, the consent might not have been properly applied. Revisit the admin consent process to ensure it's been granted for the permissions necessary to use the admin API.
Check the link below if you missed anything
https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal
Ensure that this security group is designated as a Power BI service admin group in the Power BI Admin Portal.
Also, Can you try refreshing or creating the secret for admin and try again?
Proud to be a Super User!
Hi @rubayatyasmin ,
thanks for the quick answer!
I double checked the mentioned points:
Sadly no succes.
I found GitHub - migueesc123/PowerBIRESTAPI: A Microsoft Power BI Data Connector or Power Query Connector fo... and this works quite good in my Case. Maybe is it the only solution here. Chris webb also mentioned that the admin API is not working in power query.
Thanks and best regards.