User Profile
ejk0226
Regular Visitor
Joined 10 months ago
User Widgets
Contributions
Re: Embed for your Organization (User Owns Data) - C#, Forbidden, Invalid Token
I discussed with MS Support. If your org uses AzureAD such as https://login.microsoftonline.com and https://portal.azure.com/ but uses Power BI Gov GCC (API endoint https://api.powerbigov.us) then the scopes must be in https://analysis.usgovcloudapi.net. The primary problem was registring that API Permission within the Entra app registration. The trick to doing this is when adding the Request API Permission you must select "APIs my organization uses". Then realize that search is not a wild card search so you can't just search for Gov or Power. You have to locate the "Microsoft Power BI Government Community Cloud". That's it. Within app I only switched scopes such as https://analysis.usgovcloudapi.net/powerbi/api/Workspace.Read.All and it works. AzureAD is https://login.microsoftonline.com and Power BI endpoint is https://analysis.usgovcloudapi.net.10KViews0likes0CommentsRe: Embed for your Organization (User Owns Data) - C#, Forbidden, Invalid Token
DataNinja777 Thank you for the additional suggestion however there is a new error. I changed the AzureAd Instance to .us instead of .com. After starting the app and logging in I get error "MsalUiRequiredException: AADSTS90051: Invalid Delegation Token. Invalid national Cloud ID (0) is specified.". Searching didn't find much. This site https://learn.microsoft.com/en-us/entra/identity-platform/authentication-national-cloud seems to link the use of https://login.microsoftonline.us/ with app registration from portal.azure.us. But as previously stated my org doesn't use portal.azure.us. Article also states how to lookup the app endpoint #application-endpoints and that reports using https://login.microsoftonline.com.10KViews0likes0CommentsRe: Embed for your Organization (User Owns Data) - C#, Forbidden, Invalid Token
This is helpful. However, can I go in the other direction by configuring my application to get tokens from the government cloud? How/where do I switch that? The reports I'm after are hosted on https://app.powerbigov.us/home. This is where I have a Pro license and report users also have Pro licenses. I can navigate to commerical https://app.powerbi.com/home with my gov credentials. It shows I have a Free account type with no reports. When I do as you suggest and change my endoint then yes I get a response. It's an empty list of reports because I have no reports hosted there but at least it's a 200 OK instead of error. Reading into what you describe, it sounds like I need to get different tokens. The tokens defined (https://analysis.windows.net/powerbi/api/) came from me going into the Entra App registration (https://portal.azure.com/) and adding API permissions. I only see Power BI Service and no gov option. A quick good search pointed me to a Gov azure portal at https://portal.azure.us/ however that tells me by org/domain is not registered.10KViews0likes1CommentEmbed for your Organization (User Owns Data) - C#, Forbidden, Invalid Token
I’m getting a 403 Forbidden response. The response header X-PowerBI-Error-Info reports InvalidToken. I’ve tried various asp.net core code samples. Entra app registration api permission has delegated authority configured for Power Bi Services. The web app C# configures services like so: services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(configuration, "AzureAd") .EnableTokenAcquisitionToCallDownstreamApi(configuration.GetSection("PowerBi:RequiredScopes").Get<string[]>()) .AddInMemoryTokenCaches(); The C# call: var httpClientFactory = _httpClientFactory; // from Dependancy Injection; var tokenAcquisition = _tokenAcquisition; // from Dependancy Injection string[] scopes = { "https://analysis.windows.net/powerbi/api/Workspace.Read.All", "https://analysis.windows.net/powerbi/api/Dashboard.Read.All", "https://analysis.windows.net/powerbi/api/Report.Read.All", "https://analysis.windows.net/powerbi/api/PaginatedReport.Read.All" }; var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(scopes); var client = httpClientFactory.CreateClient(); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken); var response = await client.GetAsync("https://api.powerbigov.us/v1.0/myorg/reports"); Is it the accessToken? What content within the token should I be looking at? The oid/name in the token is correct. "aud": "https://analysis.windows.net/powerbi/api" "scp": "Dashboard.Read.All PaginatedReport.Read.All Report.Read.All Workspace.Read.All" The Power BI admin says these are the Developer settings. My understanding is these settings relate to Embed for you Customer. I'm trying to use Embed for Org because all the users in my workspace will be intenal and they already have Power BI Pro licenses. I don't need/want to pay extra for capacity to support Embed for you Customer. Are there more Tenant settings I need to look for? Then I found some wording on https://learn.microsoft.com/en-us/rest/api/power-bi/#using-a-service-principal Does that mean either use Service Principal or Scopes but not both for the tentant? How exactly do I embed Power BI reports in C# web app such that there is no need to pay for extra capacity related to Embed for your Customer?Solved11KViews0likes7Comments
Data Privacy
Microsoft Fabric Community and Privacy
To learn more about how we manage your data, please review the Microsoft Fabric Community Data Privacy guide.