Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi -
I am using PowerBIClient to get the reports and I get 'Forbidden' error back.
This is what i did:
string authorityUrl = "https://login.windows.net/common/oauth2/authorize";
string resouurceUrl = "https://analysis.windows.net/powerbi/api";
var authenticationContext = new AuthenticationContext(authorityUrl);
var credential = new ClientCredential(clientID, clientSecret);
AuthenticationResult result = authenticationContext.AcquireTokenAsync(resouurceUrl, credential).Result;
var token = new TokenCredentials(result.AccessToken, "Bearer");
using (var client = new PowerBIClient(new Uri("https://api.powerbi.com"), token))
{
ODataResponseListReport reports = client.Reports.GetReports();
}
@Anonymous wrote:
Hi -
I am using PowerBIClient to get the reports and I get 'Forbidden' error back.
This is what i did:
string authorityUrl = "https://login.windows.net/common/oauth2/authorize";
string resouurceUrl = "https://analysis.windows.net/powerbi/api";var authenticationContext = new AuthenticationContext(authorityUrl);
var credential = new ClientCredential(clientID, clientSecret);
AuthenticationResult result = authenticationContext.AcquireTokenAsync(resouurceUrl, credential).Result;
var token = new TokenCredentials(result.AccessToken, "Bearer");
using (var client = new PowerBIClient(new Uri("https://api.powerbi.com"), token)){
ODataResponseListReport reports = client.Reports.GetReports();
}
@Anonymous
Usually Forbidden error indicates the registered app doesn't have suffiecient permission, please check premissions in azure portal.
What is the scenario in your case, App Owns Data or User Owns Data? For App Owns data, a native app(no client_secret) is required that code snippet is like
// Create a user password cradentials. var credential = new UserPasswordCredential({Username}, {Password}); // Authenticate using created credentials var authenticationContext = new AuthenticationContext(AuthorityUrl); var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
Hi Eric,
Thanks for your reply. My app is not a native app.
And I checked for permissions and PowerBI Service has all the delegate permissions checked, including Read and Write reports.
Please let me know if there is anything else you can think of.
Thanks, Shilpi
@Anonymous
So you're in the scenaio Embedding with Power BI users (users own data)?
Hi @Eric_Zhang,
I went with the App owns data approach and was able to authenticate using the username and password.
Thanks for your help.
I could not authenticate a web app using the client secret though.
Thanks, Shilpi
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
7 | |
6 | |
3 | |
2 | |
2 |