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 

https://api.powerbi.com/v1.0/myorg/reports/<report_it>

 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 2, 2022 in Power BI by Edureka
• 13,690 points
1,329 views

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. As @AndreyNikolov mentioned, I had to utilise JavaScript SDK, but his references were a little out of date, and some of the information there is no longer relevant, but they were still helpful. Anyway, let's start from the beginning: I had to include WebView in the xaml file as follows:

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.

Empower Your Data Insights with Power BI Certification.

answered Mar 2, 2022 by gaurav
• 23,580 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
7,139 views
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,420 points
5,894 views
0 votes
1 answer

How can I reduce the size of a Power BI file (PBIX) when working with large datasets?

Here are the most common ways to ...READ MORE

answered Dec 18, 2024 in Power BI by anonymous
• 3,020 points

edited Mar 6 881 views
+1 vote
1 answer

How can I optimize Power BI visuals when working with extremely granular data?

Optimizing the performance of visualizations becomes critical ...READ MORE

answered Nov 8, 2024 in Power BI by pooja
• 24,450 points
707 views
+1 vote
1 answer

Why is incremental refresh not working as expected in Power BI, and how can I troubleshoot it?

In most cases, when the incremental refresh ...READ MORE

answered Nov 11, 2024 in Power BI by pooja
• 24,450 points
946 views
+1 vote
1 answer

How can I fix issues with Power BI visuals not resizing properly when viewed on different screen resolutions or devices?

In order to solve the problems associated ...READ MORE

answered Nov 11, 2024 in Power BI by pooja
• 24,450 points
1,230 views
+1 vote
1 answer
+1 vote
2 answers

How can I track and log user interactions with Power BI reports?

There should be enough room for optimum ...READ MORE

answered Nov 28, 2024 in Power BI by pooja
• 24,450 points
742 views
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 14, 2022 in Power BI by gaurav
• 23,580 points
1,984 views
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,580 points
2,027 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP