Forum Discussion

powerapps_tec's avatar
powerapps_tec
Advocate I
1 year ago
Solved

API to switch tenants in an "embed for org" application

I have an application based on the "Embed for your organization" model. For authentication, on the server-side, it uses Owin and the Microsoft.Identity.Client package. On the client-side, it uses the PowerBI REST API to perform automated dataset refreshes based on parameters supplied.

I need to extend this to work with guest users from other tenants so they can perform these automated refreshes on datasets (in a workspace) within the tenant where they have been created as guests. The manual version of this complete flow works fine. By switching the tenant in Power BI Service, the guest has access to their workspace, and they can change dataset parameters and do manual refreshes.

My question is this: is there a REST API that I can use to switch the tenant from the source to the one where the user is a guest using the tenantId? And would the access token from the source be enough to make this switch? And are there any other constraints and considerations?

I have researched this problem high and low and unfortunately, am unable to find a clean solution without dismantling the current architecture completely. Any help or guidance would be much appreciated!

Many thanks.

  • powerapps_tec's avatar
    powerapps_tec
    1 year ago

    Here is a final update. I was able to upgrade the app to .NET 6.0 and also update all packages to stable versions.
    To summarize:
    Start with sample app at: Embed Power BI report in a Power BI embedded analytics application for your organization - Power BI and use the tutorial. Use the code provided at Github.
    1) If necessary, downgrade node.js/npm to V16.20.2/V8.19.4
    2) Target framework .NET 6.0 to remove dependence on out of support .NET 5.0
    3) Update Microsoft.AspNetCore.Authentication.JwtBearer: 6.0.12
    4) Update Microsoft.AspNetCore.Authentication.OpenIdConnect: 6.0.12
    5) Update Microsoft.PowerBI.Api: 4.22.0
    6) Update Microsoft.Identity.Web: 3.9.1

    I will mark this response as a solution for anyone who is interested. And if anyone needs more info on how to use the REST API in conjunction with the sample, I can provide further details.

    Many thanks and best wishes.

12 Replies