0

I am trying to follow this PowerBI embedded example and am getting an error:

'PowerBIToken' does not contain a definition for 'CreateProvisionToken'

This MSDN article describes the CreateProvisionToken() method.

  • I installed latest Microsoft.PowerBI.Core and Microsoft.PowerBI.Api using NuGet package manager

  • included Microsoft.PowerBI.Security and Microsoft.PowerBI.Api.V1 in my project.

I also tried changing CreateProvisionToken() part to the following:

var credentials = new TokenCredentials(accessKey, "AppKey");

var client = new PowerBIClient(credentials);

var devToken = PowerBIToken. CreateDevToken(reportID, workspaceID);
using (client)
{
    var embedToken = PowerBIToken.CreateReportEmbedToken(
        collectionName, 
        workspaceID, 
        reportID);
    var embedTokenString = embedToken.Generate(accessKey);
}

Which generates a token which "looks about right", but using this token in the example html in the end of the article results in an error This content is not available when rendering the report.

What am I missing?

4

1 回答 1

2

The latest version of Power BI embedded simplifies the authentication mechanism by only support one embedded token, no other tokens anymore from Power BI blog:

https://powerbi.microsoft.com/en-us/blog/what-s-new-and-what-s-next-for-power-bi-embedded-july-2016/

We have simplified the way developers authenticate their calls to Power BI. From today on, app tokens will only be used to authenticate embedding requests and other client side requests that may be added in the future. All calls to our REST APIs will be authenticated using our API keys directly. This eliminates the need to generate app tokens each time you want to call the REST API.

You need follow up the example from Microsoft:

https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/blob/master/EmbedSample/Controllers/DashboardController.cs

于 2016-08-16T10:01:13.697 回答