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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.