Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17880

PowerBI Embedded Token with PHP application

$
0
0

Hello everyone,

I'm actually trying to integrate PowerBi report into a Symfony application. 
Now what I do is create a script to get an embedded Token:


public function __construct($azureKey, $workSpaceCollectionName, $workSpaceCollectionId, $reportId)
    {
        $this->key = $azureKey;
        $this->payload = [
            'ver' => '0.2.0',
            'type' => 'embed',
            'wcn' => $workSpaceCollectionName,
            'wid' => $workSpaceCollectionId,
            'rid' => $reportId,
            'iss' => 'PowerBISDK',
            'aud' => 'https://analysis.windows.net/powerbi/api',
            'exp' => time() + 60 * 60,
            'nbf' => time(),
        ];
    }

    public function getToken()
    {
        return JWT::encode($this->payload, $this->key);
    }


Based on documentation:
https://docs.microsoft.com/en-us/azure/power-bi-embedded/power-bi-embedded-iframe
https://stackoverflow.com/questions/36694170/power-bi-embedded-from-php-obtain-an-azure-authentication-token-oauth

And then in the view is use this JS script:

<script>
        var accessToken = $('#accessToken').data('token');
        var reportToken = $('#reportToken').data('token');

        // Read embed URL from Model
        var embedUrl = "https://embedded.powerbi.com/appTokenReportEmbed?reportId=" + reportToken;


        var embedReportId = reportToken;

        var models = window['powerbi-client'].models;

        var config = {
            type: 'report',
            accessToken: accessToken,
            embedUrl: embedUrl,
            id: embedReportId,
            settings: {
                filterPaneEnabled: false,
                navContentPaneEnabled: false
            }
        };

        // Get a reference to the embedded report HTML element
        var reportContainer = $('#reportContainer')[0];

        // Embed the report and display it within the div container.
        var report = powerbi.embed(reportContainer, config);
    </script>


But actually the system return me :
GET https://wabi-us-east2-redirect.analysis.windows.net/metadata/cluster 403 (Forbidden)

The problem is porbably with the token and especially the AzureKey. As the powerBi is now deprecated in the AzurePortal, and or not accessible for new user, i can't access it. So I have created an application in azure active directory, and link powerBi in it, and setup correct permission.
Then i have generated a key for this application, and i'm using this key to generate access token. But as you can see is not working.
So don't really know what i'm doing wrong right now? 

Does anyone have an idea? 
Thx by advance.





Viewing all articles
Browse latest Browse all 17880

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>