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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-yiruan-msft
Community Support
Community Support

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

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

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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