Forum Discussion
PowerBIClient Forbidden issue
- 8 years ago
You are mixing the directions for user versus app authentication. If you plan on the users not having accounts you don't need to pass in or use a clientID and SecretKey. Here is a code example. You will just need a username, password and clientID to login. If you want to opena report and/or dashboard you also need a workspace guid. Let me know if you have any questions.
var credential = new UserPasswordCredential(Username, Password); // Authenticate using created credentials var authenticationContext = new AuthenticationContext(AuthorityUrl); var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential); if (authenticationResult == null) { return View(new EmbedConfig() { ErrorMessage = "Authentication Failed." }); } var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer"); // Create a Power BI Client object. It will be used to call Power BI APIs. using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) { // Get a list of reports. var reports = await client.Reports.GetReportsInGroupAsync(GroupId); // Get the first report in the group. var report = reports.Value.FirstOrDefault();
Are you trying to use the App method or the User method to login? The user method just reuqires you have an account in Power BI and only allows users with Power BI accounts to access the report/dashboard. The APP login method allows you to share your reports/dashboards with users who do not have a Power BI account but requires setup in Azure.
Jim
- jamesyoung8 years agoFrequent Visitor
- Yaostha8 years agoHelper II
Hi,
Even i am facing the same issue.
My setup is similar to Junilo's setup.
I have registered my Web App in Azure and noted the ClientID and Client Secret.
I am not passing any user name and password so we are not using User Login authentication.
I have pro license trial in powerBI and I have access to many dashboards.
When we do App authentication, the app must have access to Dashboard or Workspace?
Regards,
Yasotha