My web application is in .net and communicates with powerbi to render the reports and I have registered my app in Azure AD, got the service principal.

Problem : The embed token is not being able to generate and my application crashes there

Explanation : First, my app gets the access token from azure add through service principal, and then tries to invoke powerbi with that token. It has access to powerbi since it can fetch all the datasetIDs and reportIds but when a list of those ids are created and generateToken function is called, it fails.

I made sure service principal is added in my powerbi workspace.
So, is it authentication working fine and authorisation failing? If so, any comments on how to resolve this? I have been struggling to find the solution, saw many existing blog posts,added service principal correctly not sure how can I get rid of PowerBinotauthorised exception

```
 // Create a request for getting Embed token
// This method works only with new Power BI V2 workspace experience
var tokenRequest = new GenerateTokenRequestV2(

reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(reportId) },

datasets: datasetIds.Select(datasetId => new GenerateTokenRequestV2Dataset(datasetId.ToString())).ToList(),

targetWorkspaces: targetWorkspaceId != Guid.Empty ? new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(targetWorkspaceId) } : null
);

// Generate Embed token
var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);

return embedToken;

```