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
ColinChin
New Member

Power BI Embedded Using Masteruser Returns Operation returned an invalid status code 'Unauthorized'

Hi,

 

I am trying to do the Power Bi embedded using "Masteruser" from the https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Core/Embed%20for%20your%20... sample application.

 

I have granted all permissions for my App Registrations in Azure AD. But when I run the application, it returns:

 

 

 

Operation returned an invalid status code 'Unauthorized'

at Microsoft.PowerBI.Api.EmbedTokenOperations.GenerateTokenWithHttpMessagesAsync(GenerateTokenRequestV2 requestParameters, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.EmbedTokenOperationsExtensions.GenerateTokenAsync(IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.EmbedTokenOperationsExtensions.GenerateToken(IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters)
at AppOwnsData.Services.PbiEmbedService.GetEmbedToken(Guid reportId, IList`1 datasetIds, Guid targetWorkspaceId) in D:\Rassure\PBI\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 167
at AppOwnsData.Services.PbiEmbedService.GetEmbedParams(Guid workspaceId, Guid reportId, Guid additionalDatasetId) in D:\Rassure\PBI\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 75
at AppOwnsData.Controllers.EmbedInfoController.GetEmbedInfo() in D:\Rassure\PBI\Embed for your customers\AppOwnsData\Controllers\EmbedInfoController.cs:line 45

 

 

 

I am not sure if the error needs to be fixed from AD or Power BI side.

 

My appsettings.json has these settings:

 

 

 

{
  "AzureAd": {
    "AuthenticationMode": "MasterUser",
    "AuthorityUri": "https://login.microsoftonline.com/organizations/",
    "ClientId": "xxxxxxxxx-xxxxxx-xxxxxxxx-xxxxxxxxxxxxx",
    "TenantId": "",
    "Scope": [ "https://analysis.windows.net/powerbi/api/.default" ],
    "PbiUsername": "xxxxx@yyyyyy.zzz",
    "PbiPassword": "************",
    "ClientSecret": ""
  },
  "PowerBI": {
    "WorkspaceId": "xxxxxxxxx-yyyyy-tttt-zzzz-eeeeeeeee",
    "ReportId": "xxxxxxxx-xxxxxx-47a7-xxxxxxx-xxxxxxxxxxxxx"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

 

 

 

What else I am missing?

 

regards,

Colin

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ColinChin ,

According to the error message, it seems that you havn't sufficient permission to the report. Please check if you add the related master user as a member or admin to the workspace. You can find the details in the following links.

Enable workspace access

yingyinr_0-1662021113600.png

Embed Power BI Report for Customers using App Owns Data and Master User

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ColinChin ,

According to the error message, it seems that you havn't sufficient permission to the report. Please check if you add the related master user as a member or admin to the workspace. You can find the details in the following links.

Enable workspace access

yingyinr_0-1662021113600.png

Embed Power BI Report for Customers using App Owns Data and Master User

Best Regards

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.