Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
The new Power BI API under the Microsoft.PowerBI.Api.V2 namespace has some additional functionality that I'd like to leverage, but I can't seem to get it to authenticate for the life of me.
Here's an example of how I created a client with V1:
var apiEndpoint = new Uri("https://api.powerbi.com");
var accessKey = "thisvalueisprovidedbyazure";
var credentials = new TokenCredentials(accessKey, "AppKey");
var clientV1 = new Microsoft.PowerBI.Api.V1.PowerBIClient(apiEndpoint, credentials);As implied by the fake value, that access key is provided by Azure, as you can see in "Get started with Microsoft Power BI Embedded" article here: https://docs.microsoft.com/en-us/azure/power-bi-embedded/power-bi-embedded-get-started
I could then use it with a workspaceId and collectionName (also created in Azure):
var collectionName = "my-power-bi-collection"; var workspaceId = "00000000-0000-0000-0000-000000000000"; var datasets = await client.Datasets.GetDatasetsAsync(collectionName, workspaceId);
The new API seems to be completely different, however. I tried following the example in this article and the one in the git repository readme file, but it wasn't very clear where some of these values are coming from. They seem geared toward generating an access token via username/password or AD.
In the example from github, it's not very clear what some of these values are. For example, what is the ClientId? Why is the AuthorityUrl pointing to "https://login.windows.net/common/oauth2/authorize/"? Is that required for Azure? There is also no mention of workspaces (they seem to have been replaced by groups?)
Rather than generating a new token, I tried using the token provided by Azure, and it gives me a 403 FORBIDDEN every time.
Does anyone know what is required to get the new API running against Azure Power BI workspaces?
Solved! Go to Solution.
The Power BI Embedded workspace collection is being deprecated. The new replacement is Embedding with non-Power BI users (app owns data). The correlated github demo is App Owns Data. See authentication code snippet below.
// Create a user password cradentials.
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
if (authenticationResult == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Authentication Failed."
});
}
var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
The username and password are of one Power BI Pro account. The client_id is from a registered Azure AD application. See this tutorial.
The Power BI Embedded workspace collection is being deprecated. The new replacement is Embedding with non-Power BI users (app owns data). The correlated github demo is App Owns Data. See authentication code snippet below.
// Create a user password cradentials.
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
if (authenticationResult == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Authentication Failed."
});
}
var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
The username and password are of one Power BI Pro account. The client_id is from a registered Azure AD application. See this tutorial.
Thanks, I didn't realize that v2 of the API was completely incompatible with the original workspaces. I'll go ahead and give the new way a try.
The Power BI Embedded workspace collection is being deprecated.
That's what I was afraid of. Do you know how long the existing Azure workspaces will be available and how long they'll be accessible vai API v1?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |