Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |