Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi Team,
i have a problem wtih the access token.
I try get groups and access_token on learn.microsoft.com it's successfully and received 15 items
but when i try get token with C#, i can get but i try that token on postman i receiving "return @odata.count = 0" message.
Does anyone have any ideas?
Thank you
DoDe
string tenantSpeceficAuthority = "https://login.microsoftonline.com/" + _tenantId + "/oauth2/v2.0/token";
var appConfidential = ConfidentialClientApplicationBuilder.Create(_clientID)
.WithClientSecret(_clientSecret)
.WithAuthority(tenantSpeceficAuthority)
.WithRedirectUri("http://localhost")
.Build();
string[] scopes = { "https://analysis.windows.net/powerbi/api/.default" };
var authResult = appConfidential.AcquireTokenForClient(scopes).ExecuteAsync().Result;
_accessToken = authResult.AccessToken;
Solved! Go to Solution.
Hi @v-yiruan-msft ,
i have solved my problems. We should have given permission each workspace to App Name.
but i have another problem. ı can get groups's users but can't report's users.
checked rest api doc it says use the "Admin - Reports GetReportUsersAsAdmin" method to get report users.
when it try this code i getting 401 unauthorized errror.
Which permission i should add to my app?
Hi @v-yiruan-msft ,
i have solved my problems. We should have given permission each workspace to App Name.
but i have another problem. ı can get groups's users but can't report's users.
checked rest api doc it says use the "Admin - Reports GetReportUsersAsAdmin" method to get report users.
when it try this code i getting 401 unauthorized errror.
Which permission i should add to my app?
Hi @dodefb ,
The 401 Unauthorized error usually occurs when the server is unable to authenticate the request. This could be due to incorrect credentials, insufficient permissions, or other issues related to authentication. Please review the following official documentation and check if you have gotten the proper permission.
- The user must have administrator rights (such as Office 365 Global Administrator or Power BI Service Administrator) or authenticate using a service principal.
- Delegated permissions are supported.
When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal.
Best Regards
Hi @dodefb ,
The 401 Unauthorized error usually occurs when the server is unable to authenticate the request. This could be due to incorrect credentials, insufficient permissions, or other issues related to authentication. Please review the following official documentation and check if you have gotten the proper permission.
- The user must have administrator rights (such as Office 365 Global Administrator or Power BI Service Administrator) or authenticate using a service principal.
- Delegated permissions are supported.
When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal.
Best Regards
thanks for reply, i had read that article on learn.microsoft.com but it's not clear for me.
as you know i using a service principal
What "When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal." means? what should i do?
Hi @dodefb ,
It seems like there might be an issue with the access token you are using. Could you please check the following info?
How do I get an OAuth 2.0 authentication token in C# - Stack Overflow
Best Regards
hi @v-yiruan-msft ,
i tried what you wrote but unfortunately i still taking same error (count=0)
i added all screenshots below, could you check its please.
Thank you
DD
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
16 | |
13 | |
7 | |
7 | |
6 |