Power Bi Embedded Not working Can t login with Master User

0 votes

Good day to all of you. I have a problem with probably not fully understanding how to embed PBI report in my Xamarin app.  I got my access token and I used Master User for this, but after i GET EmbedUrl and put it in Source proprety of WebView, i get a message: "Please sing in to view this report". This is a problem because my customers don't have PowerBi account and I want them to be able to see this report. Problem might be in my headers I use to get access token, so below is code I use

string url = "https://login.microsoftonline.com/" + tennant_id + "/oauth2/token"; //url to which I POST to

IEnumerable<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>()
new KeyValuePair<string, string>("authenticationType", "MasterUser"),
new KeyValuePair<string, string>("name", "<name>"),
new KeyValuePair<string, string>("workspaceId", "<workspaceId>"),
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("scope", "https://analysis.windows.net/powerbi/api/.default"),
new KeyValuePair<string, string>("resource", "https://analysis.windows.net/powerbi/api"),
new KeyValuePair<string, string>("authorityUrl", "https://login.microsoftonline.com/organizations/"),
new KeyValuePair<string, string>("urlPowerBiServiceApiRoot", "https://api.powerbi.com/"),
new KeyValuePair<string, string>("client_id", "<clientID>"),
new KeyValuePair<string, string>("username", "<username>"),
new KeyValuePair<string, string>("password", "<password>"),
new KeyValuePair<string, string>("client_secret", "<clientSecret>")

 After I get access token, I use it in GET request to 


 and I pass AuthenticationHeader as 

client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);

Then I get my embed url which I use in WebView Source property but I am not logged in. When I do login i see this report, but otherwise I can't. Where am I making a mistake/mistakes? I'm new to PowerBi embedding so please explain it like you would to a child.

Mar 10, 2022 in Power BI by Edureka
• 13,670 points

1 answer to this question.

0 votes

I figured it out, and I'll put the solution here in case anyone else runs into this in the future. I had to use the JavaScript SDK, and while some of the information there is no longer relevant, it was an excellent resource. Anyway, let's start from the beginning: I had to include WebView in the xaml file as follows:

x:Name="WVtest" HeightRequest="300" WidthRequest="50" Navigated="WVtest Navigated"> x:Name="WVtest" HeightRequest="300" WidthRequest="50" Navigated="WVtest Navigated"> x:Name="WVtest" HeightRequest="300"

Then I tried adding files from the JavaScript API, but I couldn't get them to function (because the documentation was too difficult), so I made some tweaks and used files from my github repo. These files are required in order to view your PBI Embedded report via the embed url.

After that, I added the following code to the function Object() { [native code] } code behind:

"file:/android asset/html/index.html" is the source of WVtest.Source.

This is done so that WebView knows to use the index.html file as its source. It will load this.html and its.js files in order to run the PBI client and display the PBI report.

All REST APIs to PowerBI and Azure are called in the "Navigated" event. To obtain my access token, I send a POST request. This is the URL where I send my POST request:

string url = "https://login.microsoftonline.com/" + tennant + "/oauth2/token"; string url = "https://login.microsoftonline.com/oauth2/token"; string url = "https://login.microsoftonline.com/

tennant is the tennant for your apps.

Preparing for the Power BI exam? Check out Power BI Course Content now! 

answered Mar 14, 2022 by gaurav
• 23,260 points

Related Questions In Power BI

0 votes
2 answers

Can I get rid of the grey border on the report visuals with power bi embedded?

It's just a simple css code to ...READ MORE

answered Apr 19, 2020 in Power BI by Prateek Mehta
0 votes
1 answer

Power BI not able to connect to Azure SQL with private end point

You'll need to install an on-prem gateway ...READ MORE

answered Feb 17, 2022 in Power BI by CoolCoder
• 4,400 points
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,570 points
+1 vote
1 answer

Is it possible to manage limits while using dedicated capacity power bi embedded app service?

These limits are not related to using ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 18,570 points
0 votes
1 answer

How to assign Power BI license to a new user

The assign license method of MS Graph API might ...READ MORE

answered Sep 25, 2018 in Power BI by Kalgi
• 52,360 points
0 votes
1 answer

Integrate Google Analytics data with Power BI data

When you use standard google analytics connector ...READ MORE

answered Oct 3, 2018 in Power BI by Kalgi
• 52,360 points
0 votes
1 answer

how can I connect my web api with Power BI Reports?

Go to Home > Edit Queries > ...READ MORE

answered Oct 18, 2018 in Power BI by Annie97
• 2,160 points
+1 vote
1 answer

Have column with multiple values in powerBI, for use with a slicer in power bi

It can be achieved depending on the result you ...READ MORE

answered Oct 22, 2018 in Power BI by Hannah
• 18,570 points
0 votes
1 answer

Power Bi Embedded Not working, Can't login with Master User

I figured it out, and I'll put ...READ MORE

answered Mar 2, 2022 in Power BI by gaurav
• 23,260 points
0 votes
1 answer

Method not found: Void Microsoft.PowerBI.Api.V2.PowerBIClient..ctor - Power BI Embedded

There appears to be a version difference ...READ MORE

answered Mar 14, 2022 in Power BI by gaurav
• 23,260 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP