Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
adolfomartinez
Frequent Visitor

Credencial(es) genérica(s) para Power BI Embedded

Buenos días!

 

Me podrían apoyar en saber cómo configurar una "credencial" genérica para que funcione el Power BI Embedded.

 

Actualmente en el código tengo mi credencial (correo y contraseña de Power BI), pero lo que pasa es que necesito activarle a mi correo la doble autenticación y, cuando eso sucede... mi Power BI Embedded ya no funciona porque no agarra la contraseña porque está activada la doble autenticación de Office.

 

Este es mi fragmento de código (Lo que está en rojo es donde pongo mi correo y contraseña):

protected void CargarReporte(string groupId, string reportId, string type)
{
string embedUrl = "";
string token = "";

string funcion = "";
EmbedToken embedToken;

try
{
// Create a user password cradentials.
//credential = new ClientCredential(Secrets.ClientID, Secrets.ClientSecret);
credential = new UserPasswordCredential(username, Secrets.Password);

// Authenticate using created credentials
Authorize().Wait();

using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
{
if (type == "report")
{
//Report
embedToken = client.Reports.GenerateTokenInGroup(groupId, reportId, new GenerateTokenRequest(accessLevel: "View", datasetId: datasetId));
Report report = client.Reports.GetReportInGroup(groupId, reportId);

embedUrl = report.EmbedUrl;
token = embedToken.Token;

funcion = "Reporte('" + groupId + "','" + reportId + "','" + embedUrl + "','" + token + "');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", funcion, true);
}
else if (type == "dashboard")
{
//Dashboard
embedToken = client.Dashboards.GenerateTokenInGroup(groupId, reportId, new GenerateTokenRequest(accessLevel: "View", datasetId: datasetId));
Dashboard dashboard = client.Dashboards.GetDashboardInGroup(groupId, reportId);

embedUrl = dashboard.EmbedUrl;
token = embedToken.Token;

funcion = "Dashboard('" + groupId + "','" + reportId + "','" + embedUrl + "','" + token + "');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", funcion, true);
}
}
}
catch (Exception ex)
{
Response.Write("<script>alert('Error');</script>");
}
}

private static Task Authorize()
{
return Task.Run(async () => {
authenticationResult = null;
tokenCredentials = null;

var tenantSpecificURL = authorityUrl.Replace("common", tenantId);
var authenticationContext = new AuthenticationContext(authorityUrl);

//authenticationResult = await authenticationContext.AcquireTokenAsync(resourceUrl, credential);
authenticationResult = await authenticationContext.AcquireTokenAsync(resourceUrl, Secrets.ClientID, credential);

if (authenticationResult != null)
{
tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
}
});
}

2 REPLIES 2
mflores
New Member

Buenso dias Adolfo, tengo ese mismo error que tenias tú en este mensaje del 2022. Cuando quiero acceder a visualizar un powerbi en mi aplicación web, al autetificarme sin MFA me funciona correctamente, pero al hacerlo con el MFA activado, ya me da error: 


AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000009-0000-0000-c000-000000000000'. Trace ID: b262c094-3ccd-43fb-bc59-9c3d81621402 Correlation ID: 1ea1e8cb-7241-4ab9-91ef-2d4da9455cc9 Timestamp: 2024-01-02 08:07:47Z

 

¿Pudiste solucionarlo? Te agradeceria mucho si pudieras ayudarme con este tema. Muchas gracias

 

v-yiruan-msft
Community Support
Community Support

Hi @adolfomartinez ,

Please review the following links, hope they can help you resolve the problem.

Enable server-side authentication

Two factor authentication

Authentication is done via Azure Active Directory. You have several options for multi-factor authentication.

Using ADFS:

https://azure.microsoft.com/en-us/documentation/articles/multi-factor-authentication-get-started-adf...

 

Multi-factor authentication Azure service:

https://azure.microsoft.com/en-us/services/multi-factor-authentication/

You can also get to this within the Office 365 Admin portal by going to Users > Active Users > More > Setup Azure multi-factor auth in the new O365 Admin portal.

https://support.office.com/en-us/article/Set-up-multi-factor-authentication-for-Office-365-users-8f0...


Authentication Methods Used In Power BI Embedding

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.