Forum Discussion
Authenticating with C# API V2 against Azure Power BI Workspaces
- 8 years ago
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?