dsfsw1233 2016-04-18 12:34
浏览 432
已采纳

从PHP嵌入Power BI。 获取Azure身份验证令牌OAuth

I'm trying to utilise Power BI Embedded from a PHP based website to embed a non-public Power BI document into a web page (behind a user login).

There is a C# version here that I have got running: https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/. I effectively need to replicate this in PHP).

(also see https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-get-started/)

I'm stuck trying to obtain a auth-token.

The C# site generates an auth-token that if I paste into my PHP site, I can use to load the Power BI sheet. However, I'm not sure how to generate this from PHP - presumably a curl request somewhere, but I can't work out what I need to send where? [Edit: I've been sniffing packets and it doesn't seem to make an http request to generate this, so perhaps I just need to know how to generate it myself?]. The C# is using a built in library (PowerBIToken) to do this.

public async Task<ActionResult> Report(string reportId)
    {


        var devToken = PowerBIToken.CreateDevToken(this.workspaceCollection, this.workspaceId);
        using (var client = this.CreatePowerBIClient(devToken))
        {
            var reportsResponse = await client.Reports.GetReportsAsync(this.workspaceCollection, this.workspaceId);
            var report = reportsResponse.Value.FirstOrDefault(r => r.Id == reportId);
            var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id);

            var viewModel = new ReportViewModel
            {
                Report = report,
                AccessToken = embedToken.Generate(this.accessKey)
            };

            return View(viewModel);
        }
    }

I'm looking for a simple solution where I can walk through each step rather than a bloated library if possible.

  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何抓这个函数的包wx.updateShareMenu
      • ¥15 需要数据分析!时间紧!
      • ¥15 关于免费论文查重系统的问题。
      • ¥15 朋友们,这个sim函数是出了什么问题了呢
      • ¥15 【MRT数据导入问题】MRT处理modis数据提示opening input header file怎么解决?
      • ¥15 嵌入式系统综合设计题有会的教一下嘛?
      • ¥15 yolov5转onnx验证出错
      • ¥15 proteus仿真LCD不点亮
      • ¥15 C语言红绿灯时间问题
      • ¥15 matlab仿真实现定位算法