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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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