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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
BPNJMC
Frequent Visitor

Dashboards stopped opening from application

I work for an elementary school.  We have a few dashboards that users access from a C# application and the application isn't opening the dashboards anymore.  No errors.  Just a blank page.  The application code has not changed, everything worked fine until yesterday.  I can still open/view the dashboards in Power BI with no problems (app.powerbi.com). 

 

I was thinking that perhaps the problem might have something to do with authentication, but I have no error to point me in the right direction.  I've pasted the code used to authenticate below (written by someone else), just it case that might be it.

 

I have no idea why the dashboards aren't displaying in our application all the sudden and I'm hoping someone here can point me in the correct direction. 

 

Thanks,

JMC

 

 

 

 

using Microsoft.PowerBI.Api.V2.Models;
using Microsoft.PowerBI.Api.V2;
using Microsoft.PowerBI.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using System.Threading.Tasks;

namespace CAGPAttendance
{
    public partial class CAGPAttendance : System.Web.UI.Page
    {
        private string Username = "Username";
        private string Password = "Password";
        private string ClientId = "ClientId";
        private string AuthorityUrl = "https://login.windows.net/common/oauth2/authorize";
        private string ResourceUrl = "https://analysis.windows.net/powerbi/api";
        protected string accessToken;

        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterAsyncTask(new PageAsyncTask(ReadAsync));
        }

        protected async Task ReadAsync()
        {
            string task = await generateEmbedToken();
            accessToken = task;
        }


        async Task<string> generateEmbedToken()
        {
            // Create a user password cradentials.
            var credential = new UserPasswordCredential(Username, Password);

            // Authenticate using created credentials
            var authenticationContext = new AuthenticationContext(AuthorityUrl);
            var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
            var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");

            // Initialize PowerBIClient with credentials
            var powerBIclient = new PowerBIClient(tokenCredentials);

            // BaseUri is the api endpoint, default is https://api.powerbi.com
            powerBIclient.BaseUri = new Uri("https://api.powerbi.com");

            try
            {
                // Create body where accessLevel = View, datasetId = "" by default
                var requestParameters = new GenerateTokenRequest("View", "");

                // Generate EmbedToken This function sends the POST message 
                // with all parameters and returns the token
                // first paramater is Group ID
                // second paramater is Report ID
                EmbedToken token = await powerBIclient.Reports.GenerateTokenInGroupAsync(
                    "removed",
                    "removed",
                    requestParameters);

                return token.Token;

            }
            catch (Exception exc)
            {
                return exc.ToString();
            }
        }
    }
}

 

 

 

 

1 REPLY 1
v-lionel-msft
Community Support
Community Support

Hi @BPNJMC ,

 

Please refer to the link below to try to find the problem.

Troubleshoot your embedded application 

 

Best regards,
Lionel Chen

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.