Forum Discussion
emotix
8 years agoFrequent Visitor
PowerBIClient Forbidden issue
Hi all, We're investigating the user of Power BI embedded for our SaaS app. In our scenario, we own the data and our end users would be utilizing the reports as non-power-bi users. I've been ...
- 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();
Junilo
8 years agoRegular Visitor
From my first post, it is failing at AcquireTokenAsync where it says:
AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'
AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'
Yaostha
8 years agoHelper II
Same for me if I try to run the App Owns Data sample
- Junilo8 years agoRegular Visitor
Yaostha and everyone having same issue, I have fixed mine. The key is to register the Azure AD app as a "Native" app, not "Server-side..."
See my post here: http://community.powerbi.com/t5/Developer/Obtain-Access-Token-C-App-Owns-Data-Error/m-p/301881#M8884