Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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");
}
});
}
Este es el documento relacionado, puede ver este contenido:
https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal-certificate
https://community.powerbi.com/t5/Service/Two-factor-authentication/m-p/44062
https://docs.microsoft.com/en-us/power-bi/developer/embedded/embedded-troubleshoot
https://stackoverflow.com/questions/71741322/power-bi-embedded-stuck
Saludos
Liu Yang
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |